Skip to content

Commit

Permalink
[service/featuregate] Add test for multiple namespaced gates with + i…
Browse files Browse the repository at this point in the history
…n flags (open-telemetry#4966)

Signed-off-by: Anthony J Mirabella <[email protected]>
  • Loading branch information
Aneurysm9 authored Mar 8, 2022
1 parent f980c9e commit 5e18c4a
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions service/featuregate/flags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ func TestFlagValue_basic(t *testing.T) {
input: FlagValue{"foo": true, "bar": false},
expected: "-bar,foo",
},
{
name: "multiple positive items with namespaces",
input: FlagValue{"foo.bar": true, "bar.baz": true},
expected: "bar.baz,foo.bar",
},
} {
t.Run(tc.name, func(t *testing.T) {
assert.Equal(t, tc.expected, tc.input.String())
Expand All @@ -62,6 +67,36 @@ func TestFlagValue_basic(t *testing.T) {
}
}

func TestFlagValue_withPlus(t *testing.T) {
for _, tc := range []struct {
name string
expected string
input FlagValue
}{
{
name: "single item",
input: FlagValue{"foo": true},
expected: "+foo",
},
{
name: "multiple items",
input: FlagValue{"foo": true, "bar": false},
expected: "-bar,+foo",
},
{
name: "multiple positive items with namespaces",
input: FlagValue{"foo.bar": true, "bar.baz": true},
expected: "+bar.baz,+foo.bar",
},
} {
t.Run(tc.name, func(t *testing.T) {
v := FlagValue{}
assert.NoError(t, v.Set(tc.expected))
assert.Equal(t, tc.input, v)
})
}
}

func TestFlagValue_SetSlice(t *testing.T) {
for _, tc := range []struct {
name string
Expand Down

0 comments on commit 5e18c4a

Please sign in to comment.