config_test.go 737 B

12345678910111213141516171819202122232425262728293031323334
  1. package etcdserver
  2. import (
  3. "testing"
  4. )
  5. func TestConfigVerify(t *testing.T) {
  6. tests := []struct {
  7. clusterSetting string
  8. shouldError bool
  9. }{
  10. {"", true},
  11. {"node1=http://localhost:7001,node2=http://localhost:7001", true},
  12. {"node1=http://localhost:7001,node2=http://localhost:7002", false},
  13. }
  14. for i, tt := range tests {
  15. cluster := &Cluster{}
  16. cluster.Set(tt.clusterSetting)
  17. cfg := ServerConfig{
  18. Name: "node1",
  19. Cluster: cluster,
  20. ClusterState: ClusterStateValueNew,
  21. }
  22. err := cfg.Verify()
  23. if (err == nil) && tt.shouldError {
  24. t.Errorf("#%d: Got no error where one was expected", i)
  25. }
  26. if (err != nil) && !tt.shouldError {
  27. t.Errorf("#%d: Got unexpected error: %v", i, err)
  28. }
  29. }
  30. }