summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorBen Morrison <ben@gbmor.dev>2019-05-13 00:54:04 -0400
committerBen Morrison <ben@gbmor.dev>2019-05-13 00:54:04 -0400
commit45a67221f5336e679362989358407a2583f21edf (patch)
tree58c03f91e245ca30f4b5d1d53fecdaca98370524
parent5310d08bda170e2d394d27410655283e1797b7ff (diff)
downloadgetwtxt-45a67221f5336e679362989358407a2583f21edf.tar.gz
stubbing out tests
-rw-r--r--handlers_test.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/handlers_test.go b/handlers_test.go
new file mode 100644
index 0000000..72d3304
--- /dev/null
+++ b/handlers_test.go
@@ -0,0 +1,31 @@
+package main
+
+import (
+	"fmt"
+	"log"
+	"net/http"
+	"net/http/httptest"
+	"os"
+	"testing"
+)
+
+func logToNull() {
+	hush, err := os.Open("/dev/null")
+	if err != nil {
+		log.Printf("%v\n", err)
+	}
+	log.SetOutput(hush)
+}
+
+func Test_indexHandler(t *testing.T) {
+	logToNull()
+	t.Run("indexHandler", func(t *testing.T) {
+		w := httptest.NewRecorder()
+		req := httptest.NewRequest("GET", "localhost:9001/", nil)
+		indexHandler(w, req)
+		resp := w.Result()
+		if resp.StatusCode != http.StatusOK {
+			t.Errorf(fmt.Sprintf("%v", resp.StatusCode))
+		}
+	})
+}
ref='#n147'>147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172