From a70582d75acb9989d218511ae130ea4daaed83d0 Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Fri, 25 Feb 2022 22:10:55 -0500 Subject: nvdmirror: add getFileSize() test for empty file --- nvdmirror/testdata/empty | 0 nvdmirror/util_test.go | 25 +++++++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 nvdmirror/testdata/empty create mode 100644 nvdmirror/util_test.go (limited to 'nvdmirror') diff --git a/nvdmirror/testdata/empty b/nvdmirror/testdata/empty new file mode 100644 index 0000000..e69de29 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) + } + }) + } +} -- cgit v1.2.3