(t *testing.T)
| 222 | } |
| 223 | |
| 224 | func 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"}}`, |
nothing calls this directly
no test coverage detected