summary refs log tree commit diff stats
path: root/handlers_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'handlers_test.go')
-rw-r--r--handlers_test.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/handlers_test.go b/handlers_test.go
index 66c1566..4ae7ae6 100644
--- a/handlers_test.go
+++ b/handlers_test.go
@@ -1,7 +1,9 @@
 package main
 
 import (
+	"bytes"
 	"fmt"
+	"io/ioutil"
 	"log"
 	"net/http"
 	"net/http/httptest"
@@ -98,3 +100,27 @@ func Test_apiTagsHandler(t *testing.T) {
 		}
 	})
 }
+func Test_cssHandler(t *testing.T) {
+	initTestConf()
+
+	name := "CSS Handler Test"
+	css, err := ioutil.ReadFile("assets/style.css")
+	if err != nil {
+		t.Errorf("Couldn't read assets/style.css: %v\n", err)
+	}
+
+	w := httptest.NewRecorder()
+	req := httptest.NewRequest("GET", "localhost"+testport+"/css", nil)
+
+	t.Run(name, func(t *testing.T) {
+		cssHandler(w, req)
+		resp := w.Result()
+		body, _ := ioutil.ReadAll(resp.Body)
+		if resp.StatusCode != 200 {
+			t.Errorf("cssHandler(): %v\n", resp.StatusCode)
+		}
+		if !bytes.Equal(body, css) {
+			t.Errorf("cssHandler(): Byte mismatch\n")
+		}
+	})
+}