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

Function TestGetRawGistFile

pkg/cmd/gist/shared/shared_test.go:224–317  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

222}
223
224func TestGetRawGistFile(t *testing.T) {
225 tests := []struct {
226 name string
227 response string
228 statusCode int
229 want string
230 wantErr bool
231 errContains string
232 }{
233 {
234 name: "successful request",
235 response: "Hello, World!",
236 statusCode: http.StatusOK,
237 want: "Hello, World!",
238 wantErr: false,
239 },
240 {
241 name: "empty response",
242 response: "",
243 statusCode: http.StatusOK,
244 want: "",
245 wantErr: false,
246 },
247 {
248 name: "not found error",
249 response: "Not Found",
250 statusCode: http.StatusNotFound,
251 want: "",
252 wantErr: true,
253 errContains: "HTTP 404",
254 },
255 {
256 name: "server error",
257 response: "Internal Server Error",
258 statusCode: http.StatusInternalServerError,
259 want: "",
260 wantErr: true,
261 errContains: "HTTP 500",
262 },
263 {
264 name: "large content",
265 response: "This is a very large file content with multiple lines\nLine 2\nLine 3\nAnd more content...",
266 statusCode: http.StatusOK,
267 want: "This is a very large file content with multiple lines\nLine 2\nLine 3\nAnd more content...",
268 wantErr: false,
269 },
270 {
271 name: "special characters",
272 response: "Special chars: àáâãäåæçèéêë 中文 🎉 \"quotes\" 'single'",
273 statusCode: http.StatusOK,
274 want: "Special chars: àáâãäåæçèéêë 中文 🎉 \"quotes\" 'single'",
275 wantErr: false,
276 },
277 {
278 name: "JSON content",
279 response: `{"name": "test", "version": "1.0.0", "dependencies": {"lodash": "^4.17.21"}}`,
280 statusCode: http.StatusOK,
281 want: `{"name": "test", "version": "1.0.0", "dependencies": {"lodash": "^4.17.21"}}`,

Callers

nothing calls this directly

Calls 11

RegisterMethod · 0.95
VerifyMethod · 0.95
RESTFunction · 0.92
StatusStringResponseFunction · 0.92
NewImmutableSafeURLFunction · 0.92
GetRawGistFileFunction · 0.85
ContainsMethod · 0.80
EqualMethod · 0.80
RawMethod · 0.80
RunMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected