|
|
@@ -4,24 +4,39 @@ import (
|
|
|
"testing"
|
|
|
)
|
|
|
|
|
|
-func TestConfigVerify(t *testing.T) {
|
|
|
+func TestBootstrapConfigVerify(t *testing.T) {
|
|
|
tests := []struct {
|
|
|
clusterSetting string
|
|
|
+ clst ClusterState
|
|
|
+ disc string
|
|
|
shouldError bool
|
|
|
}{
|
|
|
- {"", true},
|
|
|
- {"node1=http://localhost:7001,node2=http://localhost:7001", true},
|
|
|
- {"node1=http://localhost:7001,node2=http://localhost:7002", false},
|
|
|
+ {"", ClusterStateValueNew, "", true},
|
|
|
+ {"", "", "http://discovery", true},
|
|
|
+ {
|
|
|
+ "node1=http://localhost:7001,node2=http://localhost:7001",
|
|
|
+ ClusterStateValueNew, "", true,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "node1=http://localhost:7001,node2=http://localhost:7002",
|
|
|
+ ClusterStateValueNew, "", false,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "node1=http://localhost:7001",
|
|
|
+ "", "http://discovery", false,
|
|
|
+ },
|
|
|
}
|
|
|
|
|
|
for i, tt := range tests {
|
|
|
cluster := &Cluster{}
|
|
|
cluster.Set(tt.clusterSetting)
|
|
|
cfg := ServerConfig{
|
|
|
- Name: "node1",
|
|
|
- Cluster: cluster,
|
|
|
+ Name: "node1",
|
|
|
+ DiscoveryURL: tt.disc,
|
|
|
+ Cluster: cluster,
|
|
|
+ ClusterState: tt.clst,
|
|
|
}
|
|
|
- err := cfg.Verify()
|
|
|
+ err := cfg.VerifyBootstrapConfig()
|
|
|
if (err == nil) && tt.shouldError {
|
|
|
t.Errorf("#%d: Got no error where one was expected", i)
|
|
|
}
|