diff --git a/cmd/muxt/testdata/generate/generate_env_vars.txtar b/cmd/muxt/testdata/generate/generate_env_vars.txtar new file mode 100644 index 0000000..8690009 --- /dev/null +++ b/cmd/muxt/testdata/generate/generate_env_vars.txtar @@ -0,0 +1,52 @@ +env GOPACKAGE=server + +muxt generate + +exec go test -cover + +-- template.gohtml -- +{{define "GET /" }}

Hello, world!

{{end}} + +-- go.mod -- +module server + +go 1.22 + +-- template.go -- +package server + +import ( + "embed" + "html/template" +) + +//go:embed *.gohtml +var formHTML embed.FS + +var templates = template.Must(template.ParseFS(formHTML, "*")) +-- template_test.go -- +package server + +import ( + "testing" + + "net/http" + "net/http/httptest" +) + +func Test(t *testing.T) { + mux := http.NewServeMux() + + routes(mux, nil) + + req := httptest.NewRequest(http.MethodGet, "/", nil) + rec := httptest.NewRecorder() + + mux.ServeHTTP(rec, req) + + res := rec.Result() + + if res.StatusCode != http.StatusOK { + t.Error("expected OK") + } +}