mirror of https://github.com/docker/cli.git
Refactor tests
Signed-off-by: Silvin Lubecki <silvin.lubecki@docker.com>
This commit is contained in:
parent
cc26da94ed
commit
38056740d6
|
@ -1417,58 +1417,49 @@ networks:
|
|||
}
|
||||
|
||||
func TestLoadInit(t *testing.T) {
|
||||
booleanFalse := false
|
||||
booleanTrue := true
|
||||
config, err := loadYAML(`
|
||||
booleanFalse := false
|
||||
|
||||
var testcases = []struct {
|
||||
doc string
|
||||
yaml string
|
||||
init *bool
|
||||
}{
|
||||
{
|
||||
doc: "no init defined",
|
||||
yaml: `
|
||||
version: '3.7'
|
||||
services:
|
||||
foo:
|
||||
image: alpine`)
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.DeepEqual(config, &types.Config{
|
||||
Filename: "filename.yml",
|
||||
Version: "3.7",
|
||||
Services: types.Services{
|
||||
image: alpine`,
|
||||
},
|
||||
{
|
||||
Name: "foo",
|
||||
Image: "alpine",
|
||||
},
|
||||
},
|
||||
}, cmpopts.EquateEmpty()))
|
||||
config, err = loadYAML(`
|
||||
doc: "has true init",
|
||||
yaml: `
|
||||
version: '3.7'
|
||||
services:
|
||||
foo:
|
||||
image: alpine
|
||||
init: true`)
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.DeepEqual(config, &types.Config{
|
||||
Filename: "filename.yml",
|
||||
Version: "3.7",
|
||||
Services: types.Services{
|
||||
init: true`,
|
||||
init: &booleanTrue,
|
||||
},
|
||||
{
|
||||
Name: "foo",
|
||||
Image: "alpine",
|
||||
Init: &booleanTrue,
|
||||
},
|
||||
},
|
||||
}, cmpopts.EquateEmpty()))
|
||||
config, err = loadYAML(`
|
||||
doc: "has false init",
|
||||
yaml: `
|
||||
version: '3.7'
|
||||
services:
|
||||
foo:
|
||||
image: alpine
|
||||
init: false`)
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.DeepEqual(config, &types.Config{
|
||||
Filename: "filename.yml",
|
||||
Version: "3.7",
|
||||
Services: types.Services{
|
||||
{
|
||||
Name: "foo",
|
||||
Image: "alpine",
|
||||
Init: &booleanFalse,
|
||||
init: false`,
|
||||
init: &booleanFalse,
|
||||
},
|
||||
},
|
||||
}, cmpopts.EquateEmpty()))
|
||||
}
|
||||
for _, testcase := range testcases {
|
||||
t.Run(testcase.doc, func(t *testing.T) {
|
||||
config, err := loadYAML(testcase.yaml)
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.Len(config.Services, 1))
|
||||
assert.Check(t, is.DeepEqual(config.Services[0].Init, testcase.init))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue