MCPcopy
hub / github.com/willnorris/imageproxy / TestNewRequest_BaseURL

Function TestNewRequest_BaseURL

data_test.go:246–274  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

244}
245
246func TestNewRequest_BaseURL(t *testing.T) {
247 base, _ := url.Parse("https://example.com/")
248
249 tests := []struct {
250 path string
251 want string
252 }{
253 {
254 path: "/x/path",
255 want: "https://example.com/path#0x0",
256 },
257 { // Chinese characters 已然
258 path: "/x/5bey54S2",
259 want: "https://example.com/%E5%B7%B2%E7%84%B6#0x0",
260 },
261 }
262
263 for _, tt := range tests {
264 req, _ := http.NewRequest("GET", tt.path, nil)
265 r, err := NewRequest(req, base)
266 if err != nil {
267 t.Errorf("NewRequest(%v, %v) returned unexpected error: %v", req, base, err)
268 }
269
270 if got := r.String(); got != tt.want {
271 t.Errorf("NewRequest(%v, %v) returned %q, want %q", req, base, got, tt.want)
272 }
273 }
274}

Callers

nothing calls this directly

Calls 2

StringMethod · 0.95
NewRequestFunction · 0.85

Tested by

no test coverage detected