hivedav

A curlable free/busy scheduler with CalDAV integration
git clone https://git.in0rdr.ch/hivedav.git
Log | Files | Refs | Pull requests | README | LICENSE

commit 9257d091f6435ea480c9994887a5525db8850ef2
parent 07fd6b4af84cc2cf07f0e8adedbb8eba37d620c0
Author: Andreas Gruhler <andreas.gruhler@adfinis.com>
Date:   Wed, 16 Aug 2023 00:23:59 +0200

feat(server): add basic test

Diffstat:
Aserver_test.go | 39+++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+), 0 deletions(-)

diff --git a/server_test.go b/server_test.go @@ -0,0 +1,39 @@ +package main + +import ( + "hivedav/config" + "log" + "strings" + "testing" + "net/http" + "net/http/httptest" +) + +func TestServer(t *testing.T) { + conf, err := config.LoadConfig(".") + + if err != nil { + log.Fatal("error loading config: ", err) + } + + server := &Server{conf} + + rr := httptest.NewRecorder() + + request, err := http.NewRequest("GET", "/", nil) + server.ServeHTTP(rr, request) + + if err != nil { + t.Fatal("error creating new request:", err) + } + + if status := rr.Code; status != http.StatusOK { + t.Errorf("request to / returned wrong response code. Got %v, want %v", + status, http.StatusOK) + } + + welcome := rr.Body.String() + if !strings.Contains(welcome, "hive") { + t.Errorf("request to / does not contain word 'hive'") + } +}