Skip to content

Commit

Permalink
app: Adding test for new docker client versions' capability prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
sharanyad committed Sep 29, 2017
1 parent 86a2f33 commit 64cbcbe
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions agent/app/agent_capability_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,3 +339,49 @@ func TestAWSVPCBlockInstanceMetadataWhenTaskENIIsDisabled(t *testing.T) {
}
}
}

func TestNewDockerVersionsCapabilityPrefix(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()

client := engine.NewMockDockerClient(ctrl)
conf := &config.Config{
PrivilegedDisabled:true,
}

gomock.InOrder(
client.EXPECT().SupportedVersions().Return([]dockerclient.DockerVersion{
dockerclient.Version_1_21,
dockerclient.Version_1_25,
dockerclient.Version_1_26,
}),
)
client.EXPECT().KnownVersions().Return(nil)

expectedCapabilityNames := []string{
"com.amazonaws.ecs.capability.docker-remote-api.1.21",
"ecs.capability.docker-remote-api.1.25",
"ecs.capability.docker-remote-api.1.26",
}

var expectedCapabilities []*ecs.Attribute
for _, name := range expectedCapabilityNames {
expectedCapabilities = append(expectedCapabilities,
&ecs.Attribute{Name: aws.String(name)})
}

ctx, cancel := context.WithCancel(context.TODO())
// Cancel the context to cancel async routines
defer cancel()
agent := &ecsAgent{
ctx: ctx,
dockerClient: client,
cfg: conf,
}
capabilities := agent.capabilities()

for i, expected := range expectedCapabilities {
assert.Equal(t, aws.StringValue(expected.Name), aws.StringValue(capabilities[i].Name))
assert.Equal(t, aws.StringValue(expected.Value), aws.StringValue(capabilities[i].Value))
}
}

0 comments on commit 64cbcbe

Please sign in to comment.