Skip to content

Commit

Permalink
Avoid hardcoding the number of static-resources we expect to find
Browse files Browse the repository at this point in the history
  • Loading branch information
Steve Kemp committed Aug 19, 2020
1 parent 79ba823 commit a0338d9
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion static_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ package main

import (
"io/ioutil"
"os"
"path/filepath"
"strings"
"testing"
)
Expand All @@ -14,7 +16,34 @@ import (
// Test that we have one embedded resource.
//
func TestResourceCount(t *testing.T) {
expected := 14

expected := 0

// We're going to compare what is embedded with
// what is on-disk.
//
// We could just hard-wire the count, but that
// would require updating the count every time
// we add/remove a new resource
err := filepath.Walk("data",
func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
if !info.IsDir() {
expected++
}
return nil
})
if err != nil {
t.Errorf("failed to find resources beneath data/ %s", err.Error())
}

// ARBITRARY!
if expected < 10 {
t.Fatalf("we expected more than 10 files beneath data/")
}

out := getResources()

if len(out) != expected {
Expand Down

0 comments on commit a0338d9

Please sign in to comment.