From f77d9ce238dc4c86a605770b33f27d2cb0d51eb3 Mon Sep 17 00:00:00 2001
From: Paul Duncan <pabs@pablotron.org>
Date: Mon, 31 Jan 2022 17:18:06 -0500
Subject: add Makefile, internal/cvss/v{2,31}vector_test.go

---
 Makefile                        |  7 +++++++
 internal/cvss/v2vector_test.go  | 17 +++++++++++++++++
 internal/cvss/v31vector_test.go | 19 +++++++++++++++++++
 main.go                         | 38 ++++----------------------------------
 4 files changed, 47 insertions(+), 34 deletions(-)
 create mode 100644 Makefile
 create mode 100644 internal/cvss/v2vector_test.go
 create mode 100644 internal/cvss/v31vector_test.go

diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..a9cb09b
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,7 @@
+.PHONY=all test
+
+all:
+	go1.18beta1 build
+
+test:
+	go1.18beta1 test ./...
diff --git a/internal/cvss/v2vector_test.go b/internal/cvss/v2vector_test.go
new file mode 100644
index 0000000..3ef4194
--- /dev/null
+++ b/internal/cvss/v2vector_test.go
@@ -0,0 +1,17 @@
+package cvss
+
+import "testing"
+
+// test v2 vector
+var testCvssV2 = "AV:L/AC:L/Au:N/C:N/I:N/A:P"
+
+// Test cvss v2 parser
+func TestCvssV2Parser(t *testing.T) {
+  t.Run("TestV2Parser", func(t *testing.T) {
+    // parse vector, check for error
+    _, err := NewVector(testCvssV2)
+    if err != nil {
+      t.Error(err)
+    }
+  })
+}
diff --git a/internal/cvss/v31vector_test.go b/internal/cvss/v31vector_test.go
new file mode 100644
index 0000000..8340123
--- /dev/null
+++ b/internal/cvss/v31vector_test.go
@@ -0,0 +1,19 @@
+package cvss
+
+import "testing"
+
+// test cvss v3.1 vector
+var testCvssV3 = "CVSS:3.1/AV:L/AC:L/PR:H/UI:N/S:U/C:N/I:N/A:H"
+
+// Test CVSS v3 parser.
+func TestCvssV3Parser(t *testing.T) {
+  t.Run("TestV3", func(t *testing.T) {
+    // parse vector, check for error
+    if _, err := NewVector(testCvssV3); err != nil {
+      t.Fatal(err)
+    }
+  })
+
+  // fmt.Println(v.Metrics())
+  // fmt.Println(v)
+}
diff --git a/main.go b/main.go
index 8ee6953..84e16bb 100644
--- a/main.go
+++ b/main.go
@@ -2,9 +2,9 @@ package main
 
 import (
   "encoding/json"
-  "fmt"
+  // "fmt"
   "log"
-  "nvd/internal/cvss"
+  // "nvd/internal/cvss"
   "nvd/internal/feed"
   "os"
 )
@@ -26,39 +26,9 @@ func testFeedParser() {
   }
 }
 
-// test cvss v3.1 vector
-var testCvssV3 = "CVSS:3.1/AV:L/AC:L/PR:H/UI:N/S:U/C:N/I:N/A:H"
-
-// Test CVSS v3 parser.
-func testCvssV3Parser() {
-  // parse vector, check for error
-  v, err := cvss.NewVector(testCvssV3)
-  if err != nil {
-    log.Fatal(err)
-  }
-
-  fmt.Println(v.Metrics())
-  fmt.Println(v)
-}
-
-// test cvss v2 vector
-var testCvssV2 = "AV:L/AC:L/Au:N/C:N/I:N/A:P"
-
-// Test cvss v2 parser
-func testCvssV2Parser() {
-  // parse vector, check for error
-  v, err := cvss.NewVector(testCvssV2)
-  if err != nil {
-    log.Fatal(err)
-  }
-
-  fmt.Println(v.Metrics())
-  fmt.Println(v)
-}
-
 func main() {
   // testMetaParser()
   // testFeedParser()
-  testCvssV3Parser()
-  testCvssV2Parser()
+  // testCvssV3Parser()
+  // testCvssV2Parser()
 }
-- 
cgit v1.2.3