Update some assertions.

and fix some tests

Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
Daniel Nephin
2017-12-20 17:54:31 -05:00
parent c26f37c0cc
commit 93615dd967
6 changed files with 38 additions and 35 deletions

View File

@ -47,7 +47,6 @@ func TestNewHistoryCommandSuccess(t *testing.T) {
testCases := []struct {
name string
args []string
outputRegex string
imageHistoryFunc func(img string) ([]image.HistoryResponseItem, error)
}{
{
@ -64,16 +63,17 @@ func TestNewHistoryCommandSuccess(t *testing.T) {
name: "quiet",
args: []string{"--quiet", "image:tag"},
},
// TODO: This test is failing since the output does not contain an RFC3339 date
//{
// name: "non-human",
// args: []string{"--human=false", "image:tag"},
// outputRegex: "\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}", // RFC3339 date format match
//},
{
name: "non-human-header",
args: []string{"--human=false", "image:tag"},
outputRegex: "CREATED\\sAT",
name: "non-human",
args: []string{"--human=false", "image:tag"},
imageHistoryFunc: func(img string) ([]image.HistoryResponseItem, error) {
return []image.HistoryResponseItem{{
ID: "abcdef",
Created: time.Date(2017, 1, 1, 12, 0, 3, 0, time.UTC).Unix(),
CreatedBy: "rose",
Comment: "new history item!",
}}, nil
},
},
{
name: "quiet-no-trunc",
@ -94,10 +94,6 @@ func TestNewHistoryCommandSuccess(t *testing.T) {
err := cmd.Execute()
assert.NoError(t, err)
actual := cli.OutBuffer().String()
if tc.outputRegex == "" {
golden.Assert(t, actual, fmt.Sprintf("history-command-success.%s.golden", tc.name))
} else {
assert.Regexp(t, tc.outputRegex, actual)
}
golden.Assert(t, actual, fmt.Sprintf("history-command-success.%s.golden", tc.name))
}
}

View File

@ -0,0 +1,2 @@
IMAGE CREATED AT CREATED BY SIZE COMMENT
abcdef 2017-01-01T12:00:03Z rose 0 new history item!

View File

@ -48,8 +48,8 @@ func TestRemoveStackVersion124DoesNotRemoveConfigsOrSecrets(t *testing.T) {
assert.NoError(t, cmd.Execute())
assert.Equal(t, buildObjectIDs(client.services), client.removedServices)
assert.Equal(t, buildObjectIDs(client.networks), client.removedNetworks)
assert.Nil(t, client.removedSecrets)
assert.Nil(t, client.removedConfigs)
assert.Len(t, client.removedSecrets, 0)
assert.Len(t, client.removedConfigs, 0)
}
func TestRemoveStackVersion125DoesNotRemoveConfigs(t *testing.T) {
@ -61,7 +61,7 @@ func TestRemoveStackVersion125DoesNotRemoveConfigs(t *testing.T) {
assert.Equal(t, buildObjectIDs(client.services), client.removedServices)
assert.Equal(t, buildObjectIDs(client.networks), client.removedNetworks)
assert.Equal(t, buildObjectIDs(client.secrets), client.removedSecrets)
assert.Nil(t, client.removedConfigs)
assert.Len(t, client.removedConfigs, 0)
}
func TestRemoveStackVersion130RemovesEverything(t *testing.T) {

View File

@ -7,9 +7,15 @@ import (
"github.com/stretchr/testify/assert"
)
func TestPrunePromptPre131(t *testing.T) {
func TestPrunePromptPre131DoesNotIncludeBuildCache(t *testing.T) {
cli := test.NewFakeCli(&fakeClient{version: "1.30"})
cmd := newPruneCommand(cli)
assert.NoError(t, cmd.Execute())
assert.NotContains(t, cli.OutBuffer().String(), "all build cache")
expected := `WARNING! This will remove:
- all stopped containers
- all networks not used by at least one container
- all dangling images
Are you sure you want to continue? [y/N] `
assert.Equal(t, expected, cli.OutBuffer().String())
}