MCPcopy
hub / github.com/pocketbase/pocketbase / TestFileDownload

Function TestFileDownload

apis/file_test.go:92–537  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

90}
91
92func TestFileDownload(t *testing.T) {
93 t.Parallel()
94
95 _, currentFile, _, _ := runtime.Caller(0)
96 dataDirRelPath := "../tests/data/"
97
98 testFilePath := filepath.Join(path.Dir(currentFile), dataDirRelPath, "storage/_pb_users_auth_/oap640cot4yru2s/test_kfd2wYLxkz.txt")
99 testImgPath := filepath.Join(path.Dir(currentFile), dataDirRelPath, "storage/_pb_users_auth_/4q1xlclmfloku33/300_1SEi6Q6U72.png")
100 testThumbCropCenterPath := filepath.Join(path.Dir(currentFile), dataDirRelPath, "storage/_pb_users_auth_/4q1xlclmfloku33/thumbs_300_1SEi6Q6U72.png/70x50_300_1SEi6Q6U72.png")
101 testThumbCropTopPath := filepath.Join(path.Dir(currentFile), dataDirRelPath, "storage/_pb_users_auth_/4q1xlclmfloku33/thumbs_300_1SEi6Q6U72.png/70x50t_300_1SEi6Q6U72.png")
102 testThumbCropBottomPath := filepath.Join(path.Dir(currentFile), dataDirRelPath, "storage/_pb_users_auth_/4q1xlclmfloku33/thumbs_300_1SEi6Q6U72.png/70x50b_300_1SEi6Q6U72.png")
103 testThumbFitPath := filepath.Join(path.Dir(currentFile), dataDirRelPath, "storage/_pb_users_auth_/4q1xlclmfloku33/thumbs_300_1SEi6Q6U72.png/70x50f_300_1SEi6Q6U72.png")
104 testThumbZeroWidthPath := filepath.Join(path.Dir(currentFile), dataDirRelPath, "storage/_pb_users_auth_/4q1xlclmfloku33/thumbs_300_1SEi6Q6U72.png/0x50_300_1SEi6Q6U72.png")
105 testThumbZeroHeightPath := filepath.Join(path.Dir(currentFile), dataDirRelPath, "storage/_pb_users_auth_/4q1xlclmfloku33/thumbs_300_1SEi6Q6U72.png/70x0_300_1SEi6Q6U72.png")
106
107 testFile, fileErr := os.ReadFile(testFilePath)
108 if fileErr != nil {
109 t.Fatal(fileErr)
110 }
111
112 testImg, imgErr := os.ReadFile(testImgPath)
113 if imgErr != nil {
114 t.Fatal(imgErr)
115 }
116
117 testThumbCropCenter, thumbErr := os.ReadFile(testThumbCropCenterPath)
118 if thumbErr != nil {
119 t.Fatal(thumbErr)
120 }
121
122 testThumbCropTop, thumbErr := os.ReadFile(testThumbCropTopPath)
123 if thumbErr != nil {
124 t.Fatal(thumbErr)
125 }
126
127 testThumbCropBottom, thumbErr := os.ReadFile(testThumbCropBottomPath)
128 if thumbErr != nil {
129 t.Fatal(thumbErr)
130 }
131
132 testThumbFit, thumbErr := os.ReadFile(testThumbFitPath)
133 if thumbErr != nil {
134 t.Fatal(thumbErr)
135 }
136
137 testThumbZeroWidth, thumbErr := os.ReadFile(testThumbZeroWidthPath)
138 if thumbErr != nil {
139 t.Fatal(thumbErr)
140 }
141
142 testThumbZeroHeight, thumbErr := os.ReadFile(testThumbZeroHeightPath)
143 if thumbErr != nil {
144 t.Fatal(thumbErr)
145 }
146
147 scenarios := []tests.ApiScenario{
148 {
149 Name: "missing collection",

Callers

nothing calls this directly

Calls 9

PointerFunction · 0.92
TestMethod · 0.80
OnFileDownloadRequestMethod · 0.65
NextMethod · 0.65
SettingsMethod · 0.65
SaveMethod · 0.65
UnsafeWithoutHooksMethod · 0.65
BindFuncMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…