etcd/etcdserver/config_test.go

33 lines
687 B
Go
Raw Normal View History

package etcdserver
import (
"testing"
)
func TestConfigVerify(t *testing.T) {
2014-10-07 04:05:53 +04:00
tests := []struct {
clusterSetting string
shouldError bool
}{
{"", true},
{"node1=http://localhost:7001,node2=http://localhost:7001", true},
{"node1=http://localhost:7001,node2=http://localhost:7002", false},
}
2014-10-07 04:05:53 +04:00
for i, tt := range tests {
cluster := &Cluster{}
cluster.Set(tt.clusterSetting)
cfg := ServerConfig{
2014-10-07 04:07:51 +04:00
Name: "node1",
Cluster: cluster,
2014-10-07 04:05:53 +04:00
}
err := cfg.Verify()
if (err == nil) && tt.shouldError {
t.Errorf("#%d: Got no error where one was expected", i)
}
if (err != nil) && !tt.shouldError {
t.Errorf("#%d: Got unexpected error: %v", i, err)
}
}
}