Fixes some unit tests to be able to run them on windows

Some of them are skipped for now (because the feature is not supported
or needs more work), some of them are fixed.

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
This commit is contained in:
Vincent Demeester
2018-02-27 16:54:36 +01:00
parent facb22573d
commit 0cf2e6353a
15 changed files with 435 additions and 369 deletions

View File

@ -4,6 +4,7 @@ import (
"fmt"
"io"
"io/ioutil"
"runtime"
"testing"
"github.com/docker/cli/internal/test"
@ -14,7 +15,10 @@ import (
)
func TestCreateErrors(t *testing.T) {
noSuchFile := "no such file or directory"
if runtime.GOOS == "windows" {
noSuchFile = "The system cannot find the file specified."
}
testCases := []struct {
args []string
expectedError string
@ -29,7 +33,7 @@ func TestCreateErrors(t *testing.T) {
},
{
args: []string{"plugin-foo", "nonexistent_context_dir"},
expectedError: "no such file or directory",
expectedError: noSuchFile,
},
}
@ -61,7 +65,12 @@ func TestCreateErrorOnContextDirWithoutConfig(t *testing.T) {
cmd := newCreateCommand(cli)
cmd.SetArgs([]string{"plugin-foo", tmpDir.Path()})
cmd.SetOutput(ioutil.Discard)
assert.ErrorContains(t, cmd.Execute(), "config.json: no such file or directory")
expectedErr := "config.json: no such file or directory"
if runtime.GOOS == "windows" {
expectedErr = "config.json: The system cannot find the file specified."
}
assert.ErrorContains(t, cmd.Execute(), expectedErr)
}
func TestCreateErrorOnInvalidConfig(t *testing.T) {