aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--internal/feed/meta_test.go49
-rw-r--r--main.go28
2 files changed, 50 insertions, 27 deletions
diff --git a/internal/feed/meta_test.go b/internal/feed/meta_test.go
new file mode 100644
index 0000000..04ad22b
--- /dev/null
+++ b/internal/feed/meta_test.go
@@ -0,0 +1,49 @@
+package feed
+
+import (
+ "bytes"
+ "encoding/json"
+ "testing"
+)
+
+// test data
+const testMeta = `lastModifiedDate:2022-01-29T03:01:16-05:00
+size:73202582
+zipSize:3753799
+gzSize:3753663
+sha256:B86258D5D9861507A1894A7B92011764803D7267787B1487539E240EA2405440
+`
+
+// Test meta parser
+func TestNewMeta(t *testing.T) {
+ t.Run("NewMeta", func(t *testing.T) {
+ // create buffer
+ buf := bytes.NewBufferString(testMeta)
+
+ // decode meta, check for error
+ _, err := NewMeta(buf)
+ if err != nil {
+ t.Error(err)
+ }
+ })
+
+ t.Run("JsonEncode", func(t *testing.T) {
+ // create buffer
+ buf := bytes.NewBufferString(testMeta)
+
+ // decode meta, check for error
+ meta, err := NewMeta(buf)
+ if err != nil {
+ t.Error(err)
+ }
+
+ // create destination buffer
+ var dst bytes.Buffer
+
+ // create json encoder
+ e := json.NewEncoder(&dst)
+ if err := e.Encode(meta); err != nil {
+ t.Error(err)
+ }
+ })
+}
diff --git a/main.go b/main.go
index 608d710..8ee6953 100644
--- a/main.go
+++ b/main.go
@@ -1,7 +1,6 @@
package main
import (
- "bytes"
"encoding/json"
"fmt"
"log"
@@ -10,31 +9,6 @@ import (
"os"
)
-const testMeta = `lastModifiedDate:2022-01-29T03:01:16-05:00
-size:73202582
-zipSize:3753799
-gzSize:3753663
-sha256:B86258D5D9861507A1894A7B92011764803D7267787B1487539E240EA2405440
-`
-
-// Test meta parser
-func testMetaParser() {
- // create buffer
- buf := bytes.NewBufferString(testMeta)
-
- // decode meta, check for error
- meta, err := feed.NewMeta(buf)
- if err != nil {
- log.Fatal(err)
- }
-
- // create json encoder
- e := json.NewEncoder(os.Stdout)
- if err := e.Encode(meta); err != nil {
- log.Fatal(err)
- }
-}
-
// Test feed parser
func testFeedParser() {
var f feed.Feed
@@ -83,7 +57,7 @@ func testCvssV2Parser() {
}
func main() {
- testMetaParser()
+ // testMetaParser()
// testFeedParser()
testCvssV3Parser()
testCvssV2Parser()