Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Commit

Permalink
Add coverage for ls command
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Hiltgen committed Sep 10, 2021
1 parent 1348966 commit 2c7c172
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
13 changes: 13 additions & 0 deletions integration/common/basesuites.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
package common

import (
"bytes"
"context"
"fmt"
"path"
Expand Down Expand Up @@ -120,3 +121,15 @@ func (s *BaseSuite) TestLocalOutputTarBuild() {
require.NoError(s.T(), err, "build failed")
// TODO - consider inspecting the out.tar for validity...
}

func (s *BaseSuite) TestLs() {
buf := &bytes.Buffer{}
err := RunBuildkit("ls", []string{}, RunBuildStreams{Out: buf})
require.NoError(s.T(), err, "%s: ls failed", s.Name)
lines := buf.String()
require.Contains(s.T(), lines, s.Name)

err = RunBuildkit("ls", []string{"dummy"}, RunBuildStreams{})
require.Error(s.T(), err)
require.Contains(s.T(), err.Error(), "requires exactly")
}
3 changes: 1 addition & 2 deletions pkg/cmd/ls.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package commands

import (
"fmt"
"os"
"strings"
"text/tabwriter"

Expand Down Expand Up @@ -35,7 +34,7 @@ func runLs(streams genericclioptions.IOStreams, in lsOptions) error {
builders = append(builders, b...)
}

w := tabwriter.NewWriter(os.Stdout, 0, 0, 1, ' ', 0)
w := tabwriter.NewWriter(streams.Out, 0, 0, 1, ' ', 0)
fmt.Fprintf(w, "NAME\tNODE\tDRIVER\tSTATUS\tPLATFORMS\n")

for _, b := range builders {
Expand Down

0 comments on commit 2c7c172

Please sign in to comment.