Skip to content

Commit

Permalink
add test for nil image
Browse files Browse the repository at this point in the history
  • Loading branch information
Rebecca Skinner committed Dec 15, 2016
1 parent a7c9aaa commit 3fa598d
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions resource/docker/container/container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,27 @@ func TestContainerCheck(t *testing.T) {
assert.False(t, status.HasChanges())
})

t.Run("missing image for container", func(t *testing.T) {
c := &fakeAPIClient{
FindContainerFunc: func(string) (*dc.Container, error) {
return &dc.Container{
Name: "nginx",
State: dc.State{Status: "running"},
Config: &dc.Config{}}, nil
},
FindImageFunc: func(string) (*dc.Image, error) {
return nil, nil
},
}

container := &container.Container{Force: true, Name: "nginx"}
container.SetClient(c)

_, err := container.Check(context.Background(), fakerenderer.New())

require.Error(t, err)
})

t.Run("status change", func(t *testing.T) {
c := &fakeAPIClient{
// the existing container is running the "nginx" command
Expand Down

0 comments on commit 3fa598d

Please sign in to comment.