Commit 4e9311d5 authored by Kirill Smelkov's avatar Kirill Smelkov

fixup! client_test: Add tests for NEO URI parser

- use simplified parseURL signature - DriverOptions are not passed nor changed there.
- read-only is handled by generic zodb layer not neo.parseURL .
parent 1fca6ad4
...@@ -676,27 +676,24 @@ func TestWatch(t *testing.T) { ...@@ -676,27 +676,24 @@ func TestWatch(t *testing.T) {
// TestParseURL ensures that parsing NEO URL works as expected (= following the // TestParseURL ensures that parsing NEO URL works as expected (= following the
// scheme neo(s)://[credentials@]master1,master2,...,masterN/name?options) // scheme neo(s)://[credentials@]master1,master2,...,masterN/name?options)
func TestParseURL(t *testing.T) { func TestParseURL(t *testing.T) {
o := zodb.DriverOptions{ReadOnly: true}
// Most simple valid URI // Most simple valid URI
testParseURL(t, "neo://127.0.0.1/test", urlInfo{}, o, o) testParseURL(t, "neo://127.0.0.1/test", urlInfo{})
// With 2 masters // With 2 masters
testParseURL(t, "neo://127.0.0.1,127.0.0.2/test", urlInfo{masterAddr: "127.0.0.1,127.0.0.2"}, o, o) testParseURL(t, "neo://127.0.0.1,127.0.0.2/test", urlInfo{masterAddr: "127.0.0.1,127.0.0.2"})
// With ssl // With ssl
u := "neos://ca=ca;cert=cert;key=key@127.0.0.1/test" u := "neos://ca=ca;cert=cert;key=key@127.0.0.1/test"
testParseURL(t, u, urlInfo{netcfg: neonet.Config{CA: "ca", Cert: "cert", Key: "key"}}, o, o) testParseURL(t, u, urlInfo{netcfg: neonet.Config{CA: "ca", Cert: "cert", Key: "key"}})
// With query parameters // With query parameters
u = "neo://127.0.0.1/test?read-only=true&compress=true&logfile=n.log&cache-size=256" u = "neo://127.0.0.1/test?compress=true&logfile=n.log&cache-size=256"
testParseURL(t, u, urlInfo{}, zodb.DriverOptions{}, o) testParseURL(t, u, urlInfo{})
} }
// testParseURL tests one zurl for correctness by comparing its parsed // testParseURL tests one zurl for correctness by comparing its parsed
// data with a user provided urlInfo. It also checks whether parameters // data with a user provided urlInfo.
// are propagated from a URL to DriverOptions.
// //
// Hint: testParseURL automatically sets default to undefined fields of the // Hint: testParseURL automatically sets default to undefined fields of the
// user provided urlInfo and also resets all fields to their null // user provided urlInfo.
// value after the test is finished. func testParseURL(t *testing.T, zurl string, urlinfoOk urlInfo) {
func testParseURL(t *testing.T, zurl string, urlinfoOk urlInfo, opt zodb.DriverOptions, optOk zodb.DriverOptions) {
e := func (format string, a ...interface{}) { e := func (format string, a ...interface{}) {
t.Errorf(zurl + ": " + format, a...) t.Errorf(zurl + ": " + format, a...)
} }
...@@ -706,7 +703,7 @@ func testParseURL(t *testing.T, zurl string, urlinfoOk urlInfo, opt zodb.DriverO ...@@ -706,7 +703,7 @@ func testParseURL(t *testing.T, zurl string, urlinfoOk urlInfo, opt zodb.DriverO
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
urlinfo, err := parseURL(context.Background(), u, &opt) urlinfo, err := parseURL(context.Background(), u)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
...@@ -720,10 +717,6 @@ func testParseURL(t *testing.T, zurl string, urlinfoOk urlInfo, opt zodb.DriverO ...@@ -720,10 +717,6 @@ func testParseURL(t *testing.T, zurl string, urlinfoOk urlInfo, opt zodb.DriverO
if urlinfo.netcfg != urlinfoOk.netcfg { if urlinfo.netcfg != urlinfoOk.netcfg {
e("netcfg: got %q, want %q", urlinfo.netcfg, urlinfoOk.netcfg) e("netcfg: got %q, want %q", urlinfo.netcfg, urlinfoOk.netcfg)
} }
// Test DriverOptions
if opt != optOk {
e("opt: got %v, want %v", opt, optOk)
}
} }
// setDefault sets default test values for a urlInfo // setDefault sets default test values for a urlInfo
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment