MCPcopy
hub / github.com/cli/cli / TestDeleteRun

Function TestDeleteRun

pkg/cmd/cache/delete/delete_test.go:122–488  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

120}
121
122func TestDeleteRun(t *testing.T) {
123 tests := []struct {
124 name string
125 opts DeleteOptions
126 stubs func(*httpmock.Registry)
127 tty bool
128 wantErr bool
129 wantErrMsg string
130 wantStderr string
131 wantStdout string
132 }{
133 {
134 name: "deletes cache tty",
135 opts: DeleteOptions{Identifier: "123"},
136 stubs: func(reg *httpmock.Registry) {
137 reg.Register(
138 httpmock.REST("DELETE", "repos/OWNER/REPO/actions/caches/123"),
139 httpmock.StatusStringResponse(204, ""),
140 )
141 },
142 tty: true,
143 wantStdout: "✓ Deleted 1 cache from OWNER/REPO\n",
144 },
145 {
146 name: "deletes cache notty",
147 opts: DeleteOptions{Identifier: "123"},
148 stubs: func(reg *httpmock.Registry) {
149 reg.Register(
150 httpmock.REST("DELETE", "repos/OWNER/REPO/actions/caches/123"),
151 httpmock.StatusStringResponse(204, ""),
152 )
153 },
154 tty: false,
155 wantStdout: "",
156 },
157 {
158 name: "non-existent cache",
159 opts: DeleteOptions{Identifier: "123"},
160 stubs: func(reg *httpmock.Registry) {
161 reg.Register(
162 httpmock.REST("DELETE", "repos/OWNER/REPO/actions/caches/123"),
163 httpmock.StatusStringResponse(404, ""),
164 )
165 },
166 wantErr: true,
167 wantErrMsg: "X Could not find a cache matching 123 in OWNER/REPO",
168 },
169 {
170 name: "deletes all caches",
171 opts: DeleteOptions{DeleteAll: true},
172 stubs: func(reg *httpmock.Registry) {
173 reg.Register(
174 httpmock.REST("GET", "repos/OWNER/REPO/actions/caches"),
175 httpmock.JSONResponse(shared.CachePayload{
176 ActionsCaches: []shared.Cache{
177 {
178 Id: 123,
179 Key: "foo",

Callers

nothing calls this directly

Calls 15

RegisterMethod · 0.95
VerifyMethod · 0.95
RESTFunction · 0.92
StatusStringResponseFunction · 0.92
JSONResponseFunction · 0.92
QueryMatcherFunction · 0.92
TestFunction · 0.92
NewFunction · 0.92
SetStdoutTTYMethod · 0.80
SetStdinTTYMethod · 0.80
SetStderrTTYMethod · 0.80
EqualMethod · 0.80

Tested by

no test coverage detected