diff options
author | Paul Duncan <pabs@pablotron.org> | 2022-02-25 22:10:55 -0500 |
---|---|---|
committer | Paul Duncan <pabs@pablotron.org> | 2022-02-25 22:10:55 -0500 |
commit | a70582d75acb9989d218511ae130ea4daaed83d0 (patch) | |
tree | be9e02100227611e90bbd3afb12cded2647e1049 | |
parent | d0f32435f83c78c2d00c672400ba04cbed5da97a (diff) | |
download | cvez-a70582d75acb9989d218511ae130ea4daaed83d0.tar.bz2 cvez-a70582d75acb9989d218511ae130ea4daaed83d0.zip |
nvdmirror: add getFileSize() test for empty file
-rw-r--r-- | nvdmirror/testdata/empty | 0 | ||||
-rw-r--r-- | nvdmirror/util_test.go | 25 |
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) + } + }) + } +} |