mirror of https://github.com/docker/cli.git
Fix testcases that expect trailing whitespace
and broken integration tests based of nil pointers Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
parent
db0952ad22
commit
2f8c4333fe
|
@ -111,13 +111,13 @@ func runPs(dockerCli *command.DockerCli, opts *psOptions) error {
|
|||
if len(dockerCli.ConfigFile().PsFormat) > 0 && !opts.quiet {
|
||||
format = dockerCli.ConfigFile().PsFormat
|
||||
} else {
|
||||
format = "table"
|
||||
format = formatter.TableFormatKey
|
||||
}
|
||||
}
|
||||
|
||||
containerCtx := formatter.Context{
|
||||
Output: dockerCli.Out(),
|
||||
Format: formatter.NewContainerFormat(format, opts.quiet, opts.size),
|
||||
Format: formatter.NewContainerFormat(format, opts.quiet, listOptions.Size),
|
||||
Trunc: !opts.noTrunc,
|
||||
}
|
||||
return formatter.ContainerWrite(containerCtx, containers)
|
||||
|
|
|
@ -41,7 +41,15 @@ func NewContainerFormat(source string, quiet bool, size bool) Format {
|
|||
if quiet {
|
||||
return `container_id: {{.ID}}`
|
||||
}
|
||||
format := `container_id: {{.ID}}\nimage: {{.Image}}\ncommand: {{.Command}}\ncreated_at: {{.CreatedAt}}\nstatus: {{.Status}}\nnames: {{.Names}}\nlabels: {{.Labels}}\nports: {{.Ports}}\n`
|
||||
format := `container_id: {{.ID}}
|
||||
image: {{.Image}}
|
||||
command: {{.Command}}
|
||||
created_at: {{.CreatedAt}}
|
||||
status: {{- pad .Status 1 0}}
|
||||
names: {{.Names}}
|
||||
labels: {{- pad .Labels 1 0}}
|
||||
ports: {{- pad .Ports 1 0}}
|
||||
`
|
||||
if size {
|
||||
format += `size: {{.Size}}\n`
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ func NewVolumeFormat(source string, quiet bool) Format {
|
|||
func VolumeWrite(ctx Context, volumes []*types.Volume) error {
|
||||
render := func(format func(subContext subContext) error) error {
|
||||
for _, volume := range volumes {
|
||||
if err := format(&volumeContext{v: volume}); err != nil {
|
||||
if err := format(&volumeContext{v: *volume}); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ func VolumeWrite(ctx Context, volumes []*types.Volume) error {
|
|||
|
||||
type volumeContext struct {
|
||||
HeaderContext
|
||||
v *types.Volume
|
||||
v types.Volume
|
||||
}
|
||||
|
||||
func (c *volumeContext) Name() string {
|
||||
|
|
|
@ -21,22 +21,22 @@ func TestVolumeContext(t *testing.T) {
|
|||
call func() string
|
||||
}{
|
||||
{volumeContext{
|
||||
v: &types.Volume{Name: volumeName},
|
||||
v: types.Volume{Name: volumeName},
|
||||
}, volumeName, nameHeader, ctx.Name},
|
||||
{volumeContext{
|
||||
v: &types.Volume{Driver: "driver_name"},
|
||||
v: types.Volume{Driver: "driver_name"},
|
||||
}, "driver_name", driverHeader, ctx.Driver},
|
||||
{volumeContext{
|
||||
v: &types.Volume{Scope: "local"},
|
||||
v: types.Volume{Scope: "local"},
|
||||
}, "local", scopeHeader, ctx.Scope},
|
||||
{volumeContext{
|
||||
v: &types.Volume{Mountpoint: "mountpoint"},
|
||||
v: types.Volume{Mountpoint: "mountpoint"},
|
||||
}, "mountpoint", mountpointHeader, ctx.Mountpoint},
|
||||
{volumeContext{
|
||||
v: &types.Volume{},
|
||||
v: types.Volume{},
|
||||
}, "", labelsHeader, ctx.Labels},
|
||||
{volumeContext{
|
||||
v: &types.Volume{Labels: map[string]string{"label1": "value1", "label2": "value2"}},
|
||||
v: types.Volume{Labels: map[string]string{"label1": "value1", "label2": "value2"}},
|
||||
}, "label1=value1,label2=value2", labelsHeader, ctx.Labels},
|
||||
}
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ func runImages(dockerCli *command.DockerCli, opts imagesOptions) error {
|
|||
if len(dockerCli.ConfigFile().ImagesFormat) > 0 && !opts.quiet {
|
||||
format = dockerCli.ConfigFile().ImagesFormat
|
||||
} else {
|
||||
format = "table"
|
||||
format = formatter.TableFormatKey
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ func runList(dockerCli *command.DockerCli, opts listOptions) error {
|
|||
if len(dockerCli.ConfigFile().NetworksFormat) > 0 && !opts.quiet {
|
||||
format = dockerCli.ConfigFile().NetworksFormat
|
||||
} else {
|
||||
format = "table"
|
||||
format = formatter.TableFormatKey
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ func runList(dockerCli *command.DockerCli, opts listOptions) error {
|
|||
if len(dockerCli.ConfigFile().VolumesFormat) > 0 && !opts.quiet {
|
||||
format = dockerCli.ConfigFile().VolumesFormat
|
||||
} else {
|
||||
format = "table"
|
||||
format = formatter.TableFormatKey
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue