summaryrefslogtreecommitdiff
path: root/view
diff options
context:
space:
mode:
Diffstat (limited to 'view')
-rw-r--r--view/index_test.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/view/index_test.go b/view/index_test.go
new file mode 100644
index 0000000..583032c
--- /dev/null
+++ b/view/index_test.go
@@ -0,0 +1,31 @@
+package view
+
+import (
+ "testing"
+ "net/http"
+ "net/http/httptest"
+)
+
+func TestIndexRead(t *testing.T) {
+ req, err := http.NewRequest("GET", "/", nil)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ rec := httptest.NewRecorder()
+
+ handler := http.HandlerFunc(IndexRead)
+ handler.ServeHTTP(rec, req)
+
+ if rec.Code != http.StatusSeeOther {
+ t.Errorf("Wrong status code: got %v want %v", rec.Code, http.StatusOK)
+ }
+
+ expected := `<a href="/recipes">See Other</a>.
+
+`
+ if rec.Body.String() != expected {
+ t.Errorf("Wrong response body: got '%v' want '%v'",
+ rec.Body.String(), expected)
+ }
+}