MCPcopy Create free account
hub / github.com/cli/cli / TestApp_Create

Function TestApp_Create

pkg/cmd/codespace/create_test.go:64–672  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

62}
63
64func TestApp_Create(t *testing.T) {
65 type fields struct {
66 apiClient apiClient
67 }
68 tests := []struct {
69 name string
70 fields fields
71 opts createOptions
72 wantErr error
73 wantStdout string
74 wantStderr string
75 wantURL string
76 isTTY bool
77 }{
78 {
79 name: "create codespace with default branch and 30m idle timeout",
80 fields: fields{
81 apiClient: apiCreateDefaults(&apiClientMock{
82 CreateCodespaceFunc: func(ctx context.Context, params *api.CreateCodespaceParams) (*api.Codespace, error) {
83 if params.Branch != "main" {
84 return nil, fmt.Errorf("got branch %q, want %q", params.Branch, "main")
85 }
86 if params.IdleTimeoutMinutes != 30 {
87 return nil, fmt.Errorf("idle timeout minutes was %v", params.IdleTimeoutMinutes)
88 }
89 if *params.RetentionPeriodMinutes != 2880 {
90 return nil, fmt.Errorf("retention period minutes expected 2880, was %v", params.RetentionPeriodMinutes)
91 }
92 if params.DisplayName != "" {
93 return nil, fmt.Errorf("display name was %q, expected empty", params.DisplayName)
94 }
95 return &api.Codespace{
96 Name: "monalisa-dotfiles-abcd1234",
97 }, nil
98 },
99 }),
100 },
101 opts: createOptions{
102 repo: "monalisa/dotfiles",
103 branch: "",
104 machine: "GIGA",
105 showStatus: false,
106 idleTimeout: 30 * time.Minute,
107 retentionPeriod: NullableDuration{durationPtr(48 * time.Hour)},
108 },
109 wantStdout: "monalisa-dotfiles-abcd1234\n",
110 wantStderr: " ✓ Codespaces usage for this repository is paid for by monalisa\n",
111 },
112 {
113 name: "create with explicit display name",
114 fields: fields{
115 apiClient: apiCreateDefaults(&apiClientMock{
116 CreateCodespaceFunc: func(ctx context.Context, params *api.CreateCodespaceParams) (*api.Codespace, error) {
117 if params.DisplayName != "funky flute" {
118 return nil, fmt.Errorf("expected display name %q, got %q", "funky flute", params.DisplayName)
119 }
120 return &api.Codespace{
121 Name: "monalisa-dotfiles-abcd1234",

Callers

nothing calls this directly

Calls 13

CreateMethod · 0.95
VerifyMethod · 0.95
TestFunction · 0.92
apiCreateDefaultsFunction · 0.85
durationPtrFunction · 0.85
SetStdoutTTYMethod · 0.80
SetStdinTTYMethod · 0.80
SetStderrTTYMethod · 0.80
ErrorfMethod · 0.65
RunMethod · 0.65
StringMethod · 0.65
NameMethod · 0.65

Tested by

no test coverage detected