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