MCPcopy Index your code
hub / github.com/docker/cli / TestCreateErrors

Function TestCreateErrors

cli/command/plugin/create_test.go:16–47  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

14)
15
16func TestCreateErrors(t *testing.T) {
17 noSuchFile := "no such file or directory"
18 if runtime.GOOS == "windows" {
19 noSuchFile = "The system cannot find the file specified."
20 }
21 testCases := []struct {
22 args []string
23 expectedError string
24 }{
25 {
26 args: []string{},
27 expectedError: "requires at least 2 arguments",
28 },
29 {
30 args: []string{"INVALID_TAG", "context-dir"},
31 expectedError: "invalid",
32 },
33 {
34 args: []string{"plugin-foo", "nonexistent_context_dir"},
35 expectedError: noSuchFile,
36 },
37 }
38
39 for _, tc := range testCases {
40 cli := test.NewFakeCli(&fakeClient{})
41 cmd := newCreateCommand(cli)
42 cmd.SetArgs(tc.args)
43 cmd.SetOut(io.Discard)
44 cmd.SetErr(io.Discard)
45 assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
46 }
47}
48
49func TestCreateErrorOnFileAsContextDir(t *testing.T) {
50 tmpFile := fs.NewFile(t, "file-as-context-dir")

Callers

nothing calls this directly

Calls 4

SetArgsMethod · 0.80
newCreateCommandFunction · 0.70
SetOutMethod · 0.45
SetErrMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…