Skip to content

Commit 55454c1

Browse files
committed
fix tests
- needs a trailing slash
1 parent 1003334 commit 55454c1

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

cmd/get_files.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func getFiles(fileExtension string, paths ...string) []string {
1919
} else {
2020
path = paths[0]
2121
}
22-
fileSearch := fmt.Sprintf("%s*.%s", path, fileExtension)
22+
fileSearch := fmt.Sprintf("%s/*.%s", path, fileExtension)
2323
log.Printf("%s Searching for files: %s\n", LOG_PREFIX, fileSearch)
2424
jsonFiles, err := filepath.Glob(fileSearch)
2525
check(err, "Failed to get JSON files")

cmd/get_files_test.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@ func getTempFiles() (tempFiles []string) {
1818

1919
func createTempFiles(tmpDir string) {
2020
for _, file := range getTempFiles() {
21-
filename := fmt.Sprintf("%s%s", tmpDir, file)
21+
filename := fmt.Sprintf("%s/%s", tmpDir, file)
2222
_, err := os.Create(filename)
2323
if err != nil {
24-
log.Fatalf("Failed to create file: %s", file)
24+
log.Fatalf("Failed to create file: %s", filename)
2525
}
2626
}
2727
}
2828

2929
func removeTempFiles(tmpDir string) {
3030
for _, file := range getTempFiles() {
31-
filename := fmt.Sprintf("%s%s", tmpDir, file)
31+
filename := fmt.Sprintf("%s/%s", tmpDir, file)
3232
f, err := os.Open(filename)
3333
check(err, "Failed to open file")
3434
f.Close()
@@ -45,10 +45,10 @@ func TestGetFiles(t *testing.T) {
4545
createTempFiles(tmpDir)
4646

4747
want := []string{
48-
fmt.Sprintf("%s2024.json", tmpDir),
49-
fmt.Sprintf("%s2023.json", tmpDir),
50-
fmt.Sprintf("%s2022.json", tmpDir),
51-
fmt.Sprintf("%s2021.json", tmpDir),
48+
fmt.Sprintf("%s/2024.json", tmpDir),
49+
fmt.Sprintf("%s/2023.json", tmpDir),
50+
fmt.Sprintf("%s/2022.json", tmpDir),
51+
fmt.Sprintf("%s/2021.json", tmpDir),
5252
}
5353
got := getFiles("json", tmpDir)
5454
if len(got) != len(want) {

0 commit comments

Comments
 (0)