Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6d4a507

Browse files
committed
internal/opts: SetOpts,NamedSetOpts: test for optional value
The value is optional for SetOpts (and NamedSetOpts), and implied "true" when omitted. This patch adds a test-case for this. Signed-off-by: Sebastiaan van Stijn <[email protected]> (cherry picked from commit 758cca6) Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent bae46f6 commit 6d4a507

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

internal/opts/opts_test.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@ func TestSetOpts(t *testing.T) {
1414
assert.NilError(t, o.Set("feature-b=true"))
1515
assert.NilError(t, o.Set("feature-c=0"))
1616
assert.NilError(t, o.Set("feature-d=false"))
17+
assert.NilError(t, o.Set("feature-e"))
1718

18-
expected := "map[feature-a:true feature-b:true feature-c:false feature-d:false]"
19+
expected := "map[feature-a:true feature-b:true feature-c:false feature-d:false feature-e:true]"
1920
assert.Check(t, is.Equal(expected, o.String()))
2021

21-
expectedValue := map[string]bool{"feature-a": true, "feature-b": true, "feature-c": false, "feature-d": false}
22+
expectedValue := map[string]bool{"feature-a": true, "feature-b": true, "feature-c": false, "feature-d": false, "feature-e": true}
2223
assert.Check(t, is.DeepEqual(expectedValue, o.GetAll()))
2324

2425
err := o.Set("feature=not-a-bool")
@@ -34,11 +35,12 @@ func TestNamedSetOpts(t *testing.T) {
3435
assert.NilError(t, o.Set("feature-b=true"))
3536
assert.NilError(t, o.Set("feature-c=0"))
3637
assert.NilError(t, o.Set("feature-d=false"))
38+
assert.NilError(t, o.Set("feature-e"))
3739

38-
expected := "map[feature-a:true feature-b:true feature-c:false feature-d:false]"
40+
expected := "map[feature-a:true feature-b:true feature-c:false feature-d:false feature-e:true]"
3941
assert.Check(t, is.Equal(expected, o.String()))
4042

41-
expectedValue := map[string]bool{"feature-a": true, "feature-b": true, "feature-c": false, "feature-d": false}
43+
expectedValue := map[string]bool{"feature-a": true, "feature-b": true, "feature-c": false, "feature-d": false, "feature-e": true}
4244
assert.Check(t, is.DeepEqual(expectedValue, o.GetAll()))
4345

4446
err := o.Set("feature=not-a-bool")

0 commit comments

Comments
 (0)