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) {
// TestParseURL ensures that parsing NEO URL works as expected (= following the
// scheme neo(s)://[credentials@]master1,master2,...,masterN/name?options)
func TestParseURL(t *testing.T) {
o := zodb.DriverOptions{ReadOnly: true}
// 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
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
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
u = "neo://127.0.0.1/test?read-only=true&compress=true&logfile=n.log&cache-size=256"
testParseURL(t, u, urlInfo{}, zodb.DriverOptions{}, o)
u = "neo://127.0.0.1/test?compress=true&logfile=n.log&cache-size=256"
testParseURL(t, u, urlInfo{})
}
// testParseURL tests one zurl for correctness by comparing its parsed
// data with a user provided urlInfo. It also checks whether parameters
// are propagated from a URL to DriverOptions.
// data with a user provided urlInfo.
//
// Hint: testParseURL automatically sets default to undefined fields of the
// user provided urlInfo and also resets all fields to their null
// value after the test is finished.
func testParseURL(t *testing.T, zurl string, urlinfoOk urlInfo, opt zodb.DriverOptions, optOk zodb.DriverOptions) {
// user provided urlInfo.
func testParseURL(t *testing.T, zurl string, urlinfoOk urlInfo) {
e := func (format string, a ...interface{}) {
t.Errorf(zurl + ": " + format, a...)
}
......@@ -706,7 +703,7 @@ func testParseURL(t *testing.T, zurl string, urlinfoOk urlInfo, opt zodb.DriverO
if err != nil {
t.Fatal(err)
}
urlinfo, err := parseURL(context.Background(), u, &opt)
urlinfo, err := parseURL(context.Background(), u)
if err != nil {
t.Fatal(err)
}
......@@ -720,10 +717,6 @@ func testParseURL(t *testing.T, zurl string, urlinfoOk urlInfo, opt zodb.DriverO
if 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
......
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