Skip to content

Commit

Permalink
test GOPACKGE env var usage
Browse files Browse the repository at this point in the history
  • Loading branch information
crhntr committed Aug 23, 2024
1 parent db8fc5d commit b12cc12
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions cmd/muxt/testdata/generate/generate_env_vars.txtar
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
env GOPACKAGE=server

muxt generate

exec go test -cover

-- template.gohtml --
{{define "GET /" }}<h1>Hello, world!</h1>{{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")
}
}

0 comments on commit b12cc12

Please sign in to comment.