config_test.go 687 B

1234567891011121314151617181920212223242526272829303132
  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. }
  21. err := cfg.Verify()
  22. if (err == nil) && tt.shouldError {
  23. t.Errorf("#%d: Got no error where one was expected", i)
  24. }
  25. if (err != nil) && !tt.shouldError {
  26. t.Errorf("#%d: Got unexpected error: %v", i, err)
  27. }
  28. }
  29. }