Skip to content

Commit 75a9c50

Browse files
committed
add specific test for URL encoded filenames
1 parent 1252e1b commit 75a9c50

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

cmd/download_test.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,14 @@ func fakeDownloadServer(requestor, teamSlug string) *httptest.Server {
162162
fmt.Fprint(w, "this is file 1")
163163
})
164164

165-
mux.HandleFunc("/subdir/file-2#.txt", func(w http.ResponseWriter, r *http.Request) {
165+
mux.HandleFunc("/subdir/file-2.txt", func(w http.ResponseWriter, r *http.Request) {
166166
fmt.Fprint(w, "this is file 2")
167167
})
168168

169+
mux.HandleFunc("/special-char-filename#.txt", func(w http.ResponseWriter, r *http.Request) {
170+
fmt.Fprint(w, "this is a special file")
171+
})
172+
169173
mux.HandleFunc("/file-3.txt", func(w http.ResponseWriter, r *http.Request) {
170174
fmt.Fprint(w, "")
171175
})
@@ -199,9 +203,14 @@ func assertDownloadedCorrectFiles(t *testing.T, targetDir string) {
199203
},
200204
{
201205
desc: "a file in a subdirectory",
202-
path: filepath.Join(targetDir, "bogus-track", "bogus-exercise", "subdir", "file-2#.txt"),
206+
path: filepath.Join(targetDir, "bogus-track", "bogus-exercise", "subdir", "file-2.txt"),
203207
contents: "this is file 2",
204208
},
209+
{
210+
desc: "a file that requires URL encoding",
211+
path: filepath.Join(targetDir, "bogus-track", "bogus-exercise", "special-char-filename#.txt"),
212+
contents: "this is a special file",
213+
},
205214
}
206215

207216
for _, file := range expectedFiles {
@@ -238,7 +247,8 @@ const payloadTemplate = `
238247
"file_download_base_url": "%s",
239248
"files": [
240249
"/file-1.txt",
241-
"/subdir/file-2#.txt",
250+
"/subdir/file-2.txt",
251+
"/special-char-filename#.txt",
242252
"/file-3.txt"
243253
],
244254
"iteration": {

0 commit comments

Comments
 (0)