marky

Lightweight bookmarking + plaintext archive
Log | Files | Refs | README | LICENSE

static_test.go (502B)


      1 package internal
      2 
      3 import (
      4 	"net/http"
      5 	"net/http/httptest"
      6 	"testing"
      7 )
      8 
      9 func TestStaticHandlerServesIndex(t *testing.T) {
     10 	h, err := StaticHandler()
     11 	if err != nil {
     12 		t.Fatalf("StaticHandler: %v", err)
     13 	}
     14 	rr := httptest.NewRecorder()
     15 	req := httptest.NewRequest(http.MethodGet, "/", nil)
     16 	h.ServeHTTP(rr, req)
     17 	if rr.Code != http.StatusOK {
     18 		t.Fatalf("expected 200, got %d", rr.Code)
     19 	}
     20 	if body := rr.Body.String(); body == "" || len(body) < 20 {
     21 		t.Fatalf("expected non-empty index body")
     22 	}
     23 }