2021-03-20 20:40:40 +00:00
|
|
|
// SPDX-FileCopyrightText: 2021 Luke Granger-Brown <depot@lukegb.com>
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
2021-03-20 19:53:43 +00:00
|
|
|
package fuphttp_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"fmt"
|
|
|
|
"net/http"
|
|
|
|
"net/http/httptest"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"hg.lukegb.com/lukegb/depot/web/fup/fuphttp"
|
|
|
|
"hg.lukegb.com/lukegb/depot/web/fup/fupstatic"
|
|
|
|
)
|
|
|
|
|
|
|
|
var cfg = &fuphttp.Config{
|
|
|
|
Templates: fupstatic.Templates,
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestNotFound(t *testing.T) {
|
|
|
|
ctx := context.Background()
|
|
|
|
|
|
|
|
a, err := fuphttp.New(ctx, cfg)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("fuphttp.New: %v", err)
|
|
|
|
}
|
|
|
|
s := httptest.NewServer(a.Handler())
|
|
|
|
defer s.Close()
|
|
|
|
|
|
|
|
resp, err := s.Client().Get(fmt.Sprintf("%s/not-found", s.URL))
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("Get: %v", err)
|
|
|
|
}
|
|
|
|
if resp.StatusCode != http.StatusNotFound {
|
|
|
|
t.Errorf("response status was %v; want %v", resp.StatusCode, http.StatusNotFound)
|
|
|
|
}
|
|
|
|
}
|