1package tinyclient_test23import (4 "context"5 "encoding/json"6 "net/http"7 "net/http/httptest"8 "strings"9 "testing"1011 "github.com/FelineStateMachine/tinyrelay/tinyclient"12)1314type exampleBackend struct{}1516func (exampleBackend) Query(context.Context, string, []json.RawMessage, string) (any, error) {17 return nil, nil18}19func (exampleBackend) Policy() tinyclient.Policy {20 return tinyclient.DefaultPolicy(strings.Repeat("a", 64))21}22func (exampleBackend) URL() string { return "http://relay.example" }23func (exampleBackend) Slug() string { return "standalone example" }24func (exampleBackend) Identity() string { return strings.Repeat("a", 64) }2526func TestPublicBackendRendersWithoutInternalImports(t *testing.T) {27 app, err := tinyclient.New(exampleBackend{}, tinyclient.Options{})28 if err != nil {29 t.Fatal(err)30 }31 response := httptest.NewRecorder()32 app.ServeHTTP(response, httptest.NewRequest(http.MethodGet, "/", nil))33 if response.Code != http.StatusOK || !strings.Contains(response.Body.String(), "standalone example") || !strings.Contains(response.Body.String(), "<html") {34 t.Fatalf("render: %d %s", response.Code, response.Body.String())35 }36}