Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit a0338d9

Browse files
author
Steve Kemp
committedAug 19, 2020
Avoid hardcoding the number of static-resources we expect to find
1 parent 79ba823 commit a0338d9

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed
 

‎static_test.go

+30-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ package main
66

77
import (
88
"io/ioutil"
9+
"os"
10+
"path/filepath"
911
"strings"
1012
"testing"
1113
)
@@ -14,7 +16,34 @@ import (
1416
// Test that we have one embedded resource.
1517
//
1618
func TestResourceCount(t *testing.T) {
17-
expected := 14
19+
20+
expected := 0
21+
22+
// We're going to compare what is embedded with
23+
// what is on-disk.
24+
//
25+
// We could just hard-wire the count, but that
26+
// would require updating the count every time
27+
// we add/remove a new resource
28+
err := filepath.Walk("data",
29+
func(path string, info os.FileInfo, err error) error {
30+
if err != nil {
31+
return err
32+
}
33+
if !info.IsDir() {
34+
expected++
35+
}
36+
return nil
37+
})
38+
if err != nil {
39+
t.Errorf("failed to find resources beneath data/ %s", err.Error())
40+
}
41+
42+
// ARBITRARY!
43+
if expected < 10 {
44+
t.Fatalf("we expected more than 10 files beneath data/")
45+
}
46+
1847
out := getResources()
1948

2049
if len(out) != expected {

0 commit comments

Comments
 (0)
Please sign in to comment.