Commit 9230831a authored by Joshua Gutow's avatar Joshua Gutow Committed by GitHub

Update TestUniqueFlags to check for uniqueness in aliases (#8661)

parent 03ec6db6
...@@ -26,13 +26,14 @@ func TestOptionalFlagsDontSetRequired(t *testing.T) { ...@@ -26,13 +26,14 @@ func TestOptionalFlagsDontSetRequired(t *testing.T) {
func TestUniqueFlags(t *testing.T) { func TestUniqueFlags(t *testing.T) {
seenCLI := make(map[string]struct{}) seenCLI := make(map[string]struct{})
for _, flag := range Flags { for _, flag := range Flags {
name := flag.Names()[0] for _, name := range flag.Names() {
if _, ok := seenCLI[name]; ok { if _, ok := seenCLI[name]; ok {
t.Errorf("duplicate flag %s", name) t.Errorf("duplicate flag %s", name)
continue continue
} }
seenCLI[name] = struct{}{} seenCLI[name] = struct{}{}
} }
}
} }
// TestBetaFlags test that all flags starting with "beta." have "BETA_" in the env var, and vice versa. // TestBetaFlags test that all flags starting with "beta." have "BETA_" in the env var, and vice versa.
......
...@@ -17,13 +17,14 @@ import ( ...@@ -17,13 +17,14 @@ import (
func TestUniqueFlags(t *testing.T) { func TestUniqueFlags(t *testing.T) {
seenCLI := make(map[string]struct{}) seenCLI := make(map[string]struct{})
for _, flag := range Flags { for _, flag := range Flags {
name := flag.Names()[0] for _, name := range flag.Names() {
if _, ok := seenCLI[name]; ok { if _, ok := seenCLI[name]; ok {
t.Errorf("duplicate flag %s", name) t.Errorf("duplicate flag %s", name)
continue continue
} }
seenCLI[name] = struct{}{} seenCLI[name] = struct{}{}
} }
}
} }
// TestUniqueEnvVars asserts that all flag env vars are unique, to avoid accidental conflicts between the many flags. // TestUniqueEnvVars asserts that all flag env vars are unique, to avoid accidental conflicts between the many flags.
......
...@@ -25,13 +25,14 @@ func TestOptionalFlagsDontSetRequired(t *testing.T) { ...@@ -25,13 +25,14 @@ func TestOptionalFlagsDontSetRequired(t *testing.T) {
func TestUniqueFlags(t *testing.T) { func TestUniqueFlags(t *testing.T) {
seenCLI := make(map[string]struct{}) seenCLI := make(map[string]struct{})
for _, flag := range Flags { for _, flag := range Flags {
name := flag.Names()[0] for _, name := range flag.Names() {
if _, ok := seenCLI[name]; ok { if _, ok := seenCLI[name]; ok {
t.Errorf("duplicate flag %s", name) t.Errorf("duplicate flag %s", name)
continue continue
} }
seenCLI[name] = struct{}{} seenCLI[name] = struct{}{}
} }
}
} }
// TestBetaFlags test that all flags starting with "beta." have "BETA_" in the env var, and vice versa. // TestBetaFlags test that all flags starting with "beta." have "BETA_" in the env var, and vice versa.
......
...@@ -12,13 +12,14 @@ import ( ...@@ -12,13 +12,14 @@ import (
func TestUniqueFlags(t *testing.T) { func TestUniqueFlags(t *testing.T) {
seenCLI := make(map[string]struct{}) seenCLI := make(map[string]struct{})
for _, flag := range Flags { for _, flag := range Flags {
name := flag.Names()[0] for _, name := range flag.Names() {
if _, ok := seenCLI[name]; ok { if _, ok := seenCLI[name]; ok {
t.Errorf("duplicate flag %s", name) t.Errorf("duplicate flag %s", name)
continue continue
} }
seenCLI[name] = struct{}{} seenCLI[name] = struct{}{}
} }
}
} }
// TestUniqueEnvVars asserts that all flag env vars are unique, to avoid accidental conflicts between the many flags. // TestUniqueEnvVars asserts that all flag env vars are unique, to avoid accidental conflicts between the many flags.
......
...@@ -26,13 +26,14 @@ func TestOptionalFlagsDontSetRequired(t *testing.T) { ...@@ -26,13 +26,14 @@ func TestOptionalFlagsDontSetRequired(t *testing.T) {
func TestUniqueFlags(t *testing.T) { func TestUniqueFlags(t *testing.T) {
seenCLI := make(map[string]struct{}) seenCLI := make(map[string]struct{})
for _, flag := range Flags { for _, flag := range Flags {
name := flag.Names()[0] for _, name := range flag.Names() {
if _, ok := seenCLI[name]; ok { if _, ok := seenCLI[name]; ok {
t.Errorf("duplicate flag %s", name) t.Errorf("duplicate flag %s", name)
continue continue
} }
seenCLI[name] = struct{}{} seenCLI[name] = struct{}{}
} }
}
} }
// TestBetaFlags test that all flags starting with "beta." have "BETA_" in the env var, and vice versa. // TestBetaFlags test that all flags starting with "beta." have "BETA_" in the env var, and vice versa.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment