Merge pull request #5980 from thaJeztah/container_use_subtests
cli/command/container: TestNewCreateCommandWithContentTrustErrors use subtests
This commit is contained in:
commit
33494921b8
@ -248,23 +248,25 @@ func TestNewCreateCommandWithContentTrustErrors(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
fakeCLI := test.NewFakeCli(&fakeClient{
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
createContainerFunc: func(config *container.Config,
|
fakeCLI := test.NewFakeCli(&fakeClient{
|
||||||
hostConfig *container.HostConfig,
|
createContainerFunc: func(config *container.Config,
|
||||||
networkingConfig *network.NetworkingConfig,
|
hostConfig *container.HostConfig,
|
||||||
platform *specs.Platform,
|
networkingConfig *network.NetworkingConfig,
|
||||||
containerName string,
|
platform *specs.Platform,
|
||||||
) (container.CreateResponse, error) {
|
containerName string,
|
||||||
return container.CreateResponse{}, errors.New("shouldn't try to pull image")
|
) (container.CreateResponse, error) {
|
||||||
},
|
return container.CreateResponse{}, errors.New("shouldn't try to pull image")
|
||||||
}, test.EnableContentTrust)
|
},
|
||||||
fakeCLI.SetNotaryClient(tc.notaryFunc)
|
}, test.EnableContentTrust)
|
||||||
cmd := NewCreateCommand(fakeCLI)
|
fakeCLI.SetNotaryClient(tc.notaryFunc)
|
||||||
cmd.SetOut(io.Discard)
|
cmd := NewCreateCommand(fakeCLI)
|
||||||
cmd.SetErr(io.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetErr(io.Discard)
|
||||||
err := cmd.Execute()
|
cmd.SetArgs(tc.args)
|
||||||
assert.ErrorContains(t, err, tc.expectedError)
|
err := cmd.Execute()
|
||||||
|
assert.ErrorContains(t, err, tc.expectedError)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user