mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
client: ExecCreateResult: define local type with ID field
The `ExecCreateResult` was embedding the `container.ExecCreateRespons`,
which in itself was an alias for `common.IDResponse`. This type has a
single field (`ID`) currently, but the embedding made it awkward to use,
for example, when mocking a `ExecCreateResult` using struct-literals:
func execCreateWithID(_ string, _ client.ExecCreateOptions) (client.ExecCreateResult, error) {
return client.ExecCreateResult{ExecCreateResponse: container.ExecCreateResponse{ID: "execid"}}, nil
}
This patch defines it as a local type with the `ID` as field.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@@ -25,7 +25,7 @@ func TestEventsExecDie(t *testing.T) {
|
||||
|
||||
cID := container.Run(ctx, t, apiClient)
|
||||
|
||||
id, err := apiClient.ExecCreate(ctx, cID, client.ExecCreateOptions{
|
||||
res, err := apiClient.ExecCreate(ctx, cID, client.ExecCreateOptions{
|
||||
Cmd: []string{"echo", "hello"},
|
||||
})
|
||||
assert.NilError(t, err)
|
||||
@@ -34,7 +34,7 @@ func TestEventsExecDie(t *testing.T) {
|
||||
Filters: make(client.Filters).Add("container", cID).Add("event", string(events.ActionExecDie)),
|
||||
})
|
||||
|
||||
_, err = apiClient.ExecStart(ctx, id.ID, client.ExecStartOptions{
|
||||
_, err = apiClient.ExecStart(ctx, res.ID, client.ExecStartOptions{
|
||||
Detach: true,
|
||||
Tty: false,
|
||||
})
|
||||
@@ -45,7 +45,7 @@ func TestEventsExecDie(t *testing.T) {
|
||||
assert.Equal(t, m.Type, events.ContainerEventType)
|
||||
assert.Equal(t, m.Actor.ID, cID)
|
||||
assert.Equal(t, m.Action, events.ActionExecDie)
|
||||
assert.Equal(t, m.Actor.Attributes["execID"], id.ID)
|
||||
assert.Equal(t, m.Actor.Attributes["execID"], res.ID)
|
||||
assert.Equal(t, m.Actor.Attributes["exitCode"], "0")
|
||||
case err = <-errs:
|
||||
assert.NilError(t, err)
|
||||
|
||||
Reference in New Issue
Block a user