MCPcopy
hub / github.com/cli/cli / TestEdit

Function TestEdit

pkg/cmd/codespace/edit_test.go:11–144  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9)
10
11func TestEdit(t *testing.T) {
12 tests := []struct {
13 name string
14 opts editOptions
15 cliArgs []string // alternative to opts; will test command dispatcher
16 wantEdits *api.EditCodespaceParams
17 mockCodespace *api.Codespace
18 wantStdout string
19 wantStderr string
20 wantErr bool
21 errMsg string
22 }{
23 {
24 name: "edit codespace display name",
25 opts: editOptions{
26 selector: &CodespaceSelector{codespaceName: "hubot"},
27 displayName: "hubot-changed",
28 machine: "",
29 },
30 wantEdits: &api.EditCodespaceParams{
31 DisplayName: "hubot-changed",
32 },
33 mockCodespace: &api.Codespace{
34 Name: "hubot",
35 DisplayName: "hubot-changed",
36 },
37 wantStdout: "",
38 wantErr: false,
39 },
40 {
41 name: "CLI legacy --displayName",
42 cliArgs: []string{"--codespace", "hubot", "--displayName", "hubot-changed"},
43 wantEdits: &api.EditCodespaceParams{
44 DisplayName: "hubot-changed",
45 },
46 mockCodespace: &api.Codespace{
47 Name: "hubot",
48 DisplayName: "hubot-changed",
49 },
50 wantStdout: "",
51 wantStderr: "Flag --displayName has been deprecated, use `--display-name` instead\n",
52 wantErr: false,
53 },
54 {
55 name: "edit codespace machine",
56 opts: editOptions{
57 selector: &CodespaceSelector{codespaceName: "hubot"},
58 displayName: "",
59 machine: "machine",
60 },
61 wantEdits: &api.EditCodespaceParams{
62 Machine: "machine",
63 },
64 mockCodespace: &api.Codespace{
65 Name: "hubot",
66 Machine: api.CodespaceMachine{
67 Name: "machine",
68 },

Callers

nothing calls this directly

Calls 8

EditMethod · 0.95
TestFunction · 0.92
NewAppFunction · 0.85
newEditCmdFunction · 0.85
RunMethod · 0.65
ErrorfMethod · 0.65
ErrorMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected