config_test.go 623 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package discov
  2. import (
  3. "testing"
  4. "github.com/stretchr/testify/assert"
  5. )
  6. func TestConfig(t *testing.T) {
  7. tests := []struct {
  8. EtcdConf
  9. pass bool
  10. }{
  11. {
  12. EtcdConf: EtcdConf{},
  13. pass: false,
  14. },
  15. {
  16. EtcdConf: EtcdConf{
  17. Key: "any",
  18. },
  19. pass: false,
  20. },
  21. {
  22. EtcdConf: EtcdConf{
  23. Hosts: []string{"any"},
  24. },
  25. pass: false,
  26. },
  27. {
  28. EtcdConf: EtcdConf{
  29. Hosts: []string{"any"},
  30. Key: "key",
  31. },
  32. pass: true,
  33. },
  34. }
  35. for _, test := range tests {
  36. if test.pass {
  37. assert.Nil(t, test.EtcdConf.Validate())
  38. } else {
  39. assert.NotNil(t, test.EtcdConf.Validate())
  40. }
  41. }
  42. }