From 0f11a310fd7d64a697d0ed9098205b6cdd585f1b Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Tue, 6 Mar 2018 15:26:53 -0500 Subject: [PATCH] dont prompt for github creds in unit test Signed-off-by: Daniel Nephin --- cli/command/image/build_test.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cli/command/image/build_test.go b/cli/command/image/build_test.go index 38451c6ea9..6012a755c4 100644 --- a/cli/command/image/build_test.go +++ b/cli/command/image/build_test.go @@ -161,12 +161,16 @@ COPY data /data // TestRunBuildFromLocalGitHubDirNonExistingRepo tests that build contexts // starting with `github.com/` are special-cased, and the build command attempts // to clone the remote repo. +// TODO: test "context selection" logic directly when runBuild is refactored +// to support testing (ex: docker/cli#294) func TestRunBuildFromGitHubSpecialCase(t *testing.T) { cmd := NewBuildCommand(test.NewFakeCli(nil)) - cmd.SetArgs([]string{"github.com/docker/no-such-repository"}) + // Clone a small repo that exists so git doesn't prompt for credentials + cmd.SetArgs([]string{"github.com/docker/for-win"}) cmd.SetOutput(ioutil.Discard) err := cmd.Execute() - assert.ErrorContains(t, err, "unable to prepare context: unable to 'git clone'") + assert.ErrorContains(t, err, "unable to prepare context") + assert.ErrorContains(t, err, "docker-build-git") } // TestRunBuildFromLocalGitHubDirNonExistingRepo tests that a local directory