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

Function TestCreate

cli/command/context/create_test.go:58–146  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

56}
57
58func TestCreate(t *testing.T) {
59 cli := makeFakeCli(t)
60 assert.NilError(t, cli.ContextStore().CreateOrUpdate(store.Metadata{Name: "existing-context"}))
61 tests := []struct {
62 doc string
63 options createOptions
64 name string
65 expecterErr string
66 }{
67 {
68 doc: "empty name",
69 expecterErr: `context name cannot be empty`,
70 },
71 {
72 doc: "reserved name",
73 name: "default",
74 expecterErr: `"default" is a reserved context name`,
75 },
76 {
77 doc: "whitespace-only name",
78 name: " ",
79 expecterErr: `context name " " is invalid`,
80 },
81 {
82 doc: "existing context",
83 name: "existing-context",
84 expecterErr: `context "existing-context" already exists`,
85 },
86 {
87 doc: "invalid docker host",
88 name: "invalid-docker-host",
89 options: createOptions{
90 endpoint: map[string]string{
91 "host": "some///invalid/host",
92 },
93 },
94 expecterErr: `unable to parse docker host`,
95 },
96 {
97 doc: "ssh host with skip-tls-verify=false",
98 name: "skip-tls-verify-false",
99 options: createOptions{
100 endpoint: map[string]string{
101 "host": "ssh://example.com,skip-tls-verify=false",
102 },
103 },
104 },
105 {
106 doc: "ssh host with skip-tls-verify=true",
107 name: "skip-tls-verify-true",
108 options: createOptions{
109 endpoint: map[string]string{
110 "host": "ssh://example.com,skip-tls-verify=true",
111 },
112 },
113 },
114 {
115 doc: "ssh host with skip-tls-verify=INVALID",

Callers

nothing calls this directly

Calls 4

makeFakeCliFunction · 0.85
runCreateFunction · 0.70
CreateOrUpdateMethod · 0.65
ContextStoreMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…