use gotest.tools/fs for TestActivateExpiredLicenseDryRun

Signed-off-by: Andrew Hsu <andrewhsu@docker.com>
This commit is contained in:
Andrew Hsu 2018-09-28 18:31:38 +00:00 committed by Tibor Vass
parent 5a97a93ae1
commit a7488d1bcd
1 changed files with 5 additions and 10 deletions

View File

@ -2,9 +2,6 @@ package engine
import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"testing"
"github.com/docker/cli/internal/test"
@ -12,6 +9,7 @@ import (
"github.com/docker/docker/api/types"
"github.com/docker/docker/client"
"gotest.tools/assert"
"gotest.tools/fs"
"gotest.tools/golden"
)
@ -51,12 +49,9 @@ func TestActivateBadLicense(t *testing.T) {
}
func TestActivateExpiredLicenseDryRun(t *testing.T) {
tmpdir, err := ioutil.TempDir("", "license")
assert.NilError(t, err)
defer os.RemoveAll(tmpdir)
filename := filepath.Join(tmpdir, "docker.lic")
err = ioutil.WriteFile(filename, []byte(expiredLicense), 0644)
assert.NilError(t, err)
dir := fs.NewDir(t, "license", fs.WithFile("docker.lic", expiredLicense, fs.WithMode(0644)))
defer dir.Remove()
filename := dir.Join("docker.lic")
isRoot = func() bool { return true }
c := test.NewFakeCli(&verClient{client.Client{}, types.Version{}, nil})
c.SetContainerizedEngineClient(
@ -70,7 +65,7 @@ func TestActivateExpiredLicenseDryRun(t *testing.T) {
cmd.Flags().Set("license", filename)
cmd.Flags().Set("display-only", "true")
c.OutBuffer().Reset()
err = cmd.Execute()
err := cmd.Execute()
assert.NilError(t, err)
golden.Assert(t, c.OutBuffer().String(), "expired-license-display-only.golden")
}