|
|
@@ -212,6 +212,71 @@ func TestConfigParsingConflictClusteringFlags(t *testing.T) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+func TestConfigParsingMissedAdvertiseClientURLsFlag(t *testing.T) {
|
|
|
+ tests := []struct {
|
|
|
+ args []string
|
|
|
+ werr error
|
|
|
+ }{
|
|
|
+ {
|
|
|
+ []string{
|
|
|
+ "-initial-cluster=infra1=http://127.0.0.1:2380",
|
|
|
+ "-listen-client-urls=http://127.0.0.1:2379",
|
|
|
+ },
|
|
|
+ errUnsetAdvertiseClientURLsFlag,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ []string{
|
|
|
+ "-discovery-srv=example.com",
|
|
|
+ "-listen-client-urls=http://127.0.0.1:2379",
|
|
|
+ },
|
|
|
+ errUnsetAdvertiseClientURLsFlag,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ []string{
|
|
|
+ "-discovery=http://example.com/abc",
|
|
|
+ "-discovery-fallback=exit",
|
|
|
+ "-listen-client-urls=http://127.0.0.1:2379",
|
|
|
+ },
|
|
|
+ errUnsetAdvertiseClientURLsFlag,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ []string{
|
|
|
+ "-listen-client-urls=http://127.0.0.1:2379",
|
|
|
+ },
|
|
|
+ errUnsetAdvertiseClientURLsFlag,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ []string{
|
|
|
+ "-discovery=http://example.com/abc",
|
|
|
+ "-listen-client-urls=http://127.0.0.1:2379",
|
|
|
+ },
|
|
|
+ nil,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ []string{
|
|
|
+ "-proxy=on",
|
|
|
+ "-listen-client-urls=http://127.0.0.1:2379",
|
|
|
+ },
|
|
|
+ nil,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ []string{
|
|
|
+ "-proxy=readonly",
|
|
|
+ "-listen-client-urls=http://127.0.0.1:2379",
|
|
|
+ },
|
|
|
+ nil,
|
|
|
+ },
|
|
|
+ }
|
|
|
+
|
|
|
+ for i, tt := range tests {
|
|
|
+ cfg := NewConfig()
|
|
|
+ err := cfg.Parse(tt.args)
|
|
|
+ if err != tt.werr {
|
|
|
+ t.Errorf("%d: err = %v, want %v", i, err, tt.werr)
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
func TestConfigIsNewCluster(t *testing.T) {
|
|
|
tests := []struct {
|
|
|
state string
|