aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--nvdmirror/testdata/empty0
-rw-r--r--nvdmirror/util_test.go25
2 files changed, 25 insertions, 0 deletions
diff --git a/nvdmirror/testdata/empty b/nvdmirror/testdata/empty
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/nvdmirror/testdata/empty
diff --git a/nvdmirror/util_test.go b/nvdmirror/util_test.go
new file mode 100644
index 0000000..d39881e
--- /dev/null
+++ b/nvdmirror/util_test.go
@@ -0,0 +1,25 @@
+package nvdmirror
+
+import (
+ "testing"
+)
+
+func TestGetFileSize(t *testing.T) {
+ tests := []struct {
+ path string
+ exp uint64
+ } {
+ { "testdata/empty", 0 },
+ { "testdata/bad-data.json.gz", 37 },
+ }
+
+ for _, test := range(tests) {
+ t.Run(test.path, func(t *testing.T) {
+ if got, err := getFileSize(test.path); err != nil {
+ t.Error(err)
+ } else if got != test.exp {
+ t.Errorf("got %d, exp %d", got, test.exp)
+ }
+ })
+ }
+}