MCPcopy Create free account
hub / github.com/imgproxy/imgproxy / TestContentDispositionValue

Function TestContentDispositionValue

httpheaders/cdv_test.go:10–128  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

8)
9
10func TestContentDispositionValue(t *testing.T) {
11 // Test cases for ContentDispositionValue function that generates content-disposition headers
12 tests := []struct {
13 name string
14 url string
15 filename string
16 ext string
17 returnAttachment bool
18 expected string
19 contentType string
20 }{
21 {
22 name: "BasicURL",
23 url: "http://example.com/test.jpg",
24 filename: "",
25 ext: "",
26 contentType: "",
27 returnAttachment: false,
28 expected: "inline; filename=\"test.jpg\"",
29 },
30 {
31 name: "EmptyFilename",
32 url: "http://example.com/path/to/",
33 filename: "",
34 ext: "",
35 contentType: "",
36 returnAttachment: false,
37 expected: "inline; filename=\"image\"",
38 },
39 {
40 name: "EmptyFilenameWithExt",
41 url: "http://example.com/path/to/",
42 filename: "",
43 ext: ".png",
44 contentType: "",
45 returnAttachment: false,
46 expected: "inline; filename=\"image.png\"",
47 },
48 {
49 name: "EmptyFilenameWithFilenameAndExt",
50 url: "http://example.com/path/to/",
51 filename: "example",
52 ext: ".png",
53 contentType: "",
54 returnAttachment: false,
55 expected: "inline; filename=\"example.png\"",
56 },
57 {
58 name: "EmptyFilenameWithFilenameOverride",
59 url: "http://example.com/path/to/",
60 filename: "example",
61 ext: ".jpg",
62 contentType: "",
63 returnAttachment: false,
64 expected: "inline; filename=\"example.jpg\"",
65 },
66 {
67 name: "PresentFilenameWithExtOverride",

Callers

nothing calls this directly

Calls 2

ContentDispositionValueFunction · 0.92
RunMethod · 0.80

Tested by

no test coverage detected