Browse Source

Start writing tests

Matty Jorgensen 1 year ago
parent
commit
f654c233f3
3 changed files with 25 additions and 2 deletions
  1. 2 2
      .github/workflows/go.yml
  2. 3 0
      Makefile
  3. 20 0
      config_test.go

+ 2 - 2
.github/workflows/go.yml

@@ -30,5 +30,5 @@ jobs:
     - name: Build
       run: make build
 
-    #- name: Test
-    #  run: go test -v ./...
+    - name: Test
+      run: make test

+ 3 - 0
Makefile

@@ -13,3 +13,6 @@ dry-run: build
 
 build:
 	go build -o gof $(GOFLAGS) .
+
+test: build
+	go test -v ./...

+ 20 - 0
config_test.go

@@ -0,0 +1,20 @@
+package main
+
+import (
+	"fmt"
+	"testing"
+)
+
+// TestUserAgent tests User Agent
+func TestUserAgent(t *testing.T) {
+	conf := readConfig("gof.example.yaml")
+
+	if conf.HttpConfig.UserAgent == "" {
+		t.Error("UserAgent is blank")
+	}
+	expected := fmt.Sprintf("%s/%s",
+		conf.Meta.Name, conf.Meta.Version)
+	if conf.HttpConfig.UserAgent != expected {
+		t.Error("UserAgent did not match expectation")
+	}
+}