mirror of
https://github.com/coder/coder.git
synced 2026-10-24 01:26:25 +08:00
Enforces a consistent test package layout. This makes it difficult to test internal functionality, which I believe promotes healthy decomposition, and minimal package exports.
28 lines
570 B
Go
28 lines
570 B
Go
package site_test
|
|
|
|
import (
|
|
"context"
|
|
"io"
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/coder/coder/site"
|
|
)
|
|
|
|
func TestIndexPageRenders(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
srv := httptest.NewServer(site.Handler())
|
|
|
|
req, err := http.NewRequestWithContext(context.Background(), "GET", srv.URL, nil)
|
|
require.NoError(t, err)
|
|
resp, err := http.DefaultClient.Do(req)
|
|
require.NoError(t, err, "get index")
|
|
defer resp.Body.Close()
|
|
data, _ := io.ReadAll(resp.Body)
|
|
require.NotEmpty(t, data, "index should have contents")
|
|
}
|