mirror of
https://github.com/moby/moby.git
synced 2026-08-03 06:30:59 +00:00
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 <github@gone.nl>
This commit is contained in:
@@ -14,11 +14,12 @@ func TestSetOpts(t *testing.T) {
|
||||
assert.NilError(t, o.Set("feature-b=true"))
|
||||
assert.NilError(t, o.Set("feature-c=0"))
|
||||
assert.NilError(t, o.Set("feature-d=false"))
|
||||
assert.NilError(t, o.Set("feature-e"))
|
||||
|
||||
expected := "map[feature-a:true feature-b:true feature-c:false feature-d:false]"
|
||||
expected := "map[feature-a:true feature-b:true feature-c:false feature-d:false feature-e:true]"
|
||||
assert.Check(t, is.Equal(expected, o.String()))
|
||||
|
||||
expectedValue := map[string]bool{"feature-a": true, "feature-b": true, "feature-c": false, "feature-d": false}
|
||||
expectedValue := map[string]bool{"feature-a": true, "feature-b": true, "feature-c": false, "feature-d": false, "feature-e": true}
|
||||
assert.Check(t, is.DeepEqual(expectedValue, o.GetAll()))
|
||||
|
||||
err := o.Set("feature=not-a-bool")
|
||||
@@ -34,11 +35,12 @@ func TestNamedSetOpts(t *testing.T) {
|
||||
assert.NilError(t, o.Set("feature-b=true"))
|
||||
assert.NilError(t, o.Set("feature-c=0"))
|
||||
assert.NilError(t, o.Set("feature-d=false"))
|
||||
assert.NilError(t, o.Set("feature-e"))
|
||||
|
||||
expected := "map[feature-a:true feature-b:true feature-c:false feature-d:false]"
|
||||
expected := "map[feature-a:true feature-b:true feature-c:false feature-d:false feature-e:true]"
|
||||
assert.Check(t, is.Equal(expected, o.String()))
|
||||
|
||||
expectedValue := map[string]bool{"feature-a": true, "feature-b": true, "feature-c": false, "feature-d": false}
|
||||
expectedValue := map[string]bool{"feature-a": true, "feature-b": true, "feature-c": false, "feature-d": false, "feature-e": true}
|
||||
assert.Check(t, is.DeepEqual(expectedValue, o.GetAll()))
|
||||
|
||||
err := o.Set("feature=not-a-bool")
|
||||
|
||||
Reference in New Issue
Block a user