Skip to content

Commit

Permalink
Merge pull request #469 from coder/mafredri/fix-coverage4
Browse files Browse the repository at this point in the history
Clean out env passed to wasmbrowsertest in TestWasm
  • Loading branch information
mafredri authored Aug 15, 2024
2 parents 418f92e + dee24ac commit f8c1853
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion conn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,14 +364,26 @@ func TestWasm(t *testing.T) {
defer cancel()

cmd := exec.CommandContext(ctx, "go", "test", "-exec=wasmbrowsertest", ".", "-v")
cmd.Env = append(os.Environ(), "GOOS=js", "GOARCH=wasm", fmt.Sprintf("WS_ECHO_SERVER_URL=%v", s.URL))
cmd.Env = append(cleanEnv(os.Environ()), "GOOS=js", "GOARCH=wasm", fmt.Sprintf("WS_ECHO_SERVER_URL=%v", s.URL))

b, err := cmd.CombinedOutput()
if err != nil {
t.Fatalf("wasm test binary failed: %v:\n%s", err, b)
}
}

func cleanEnv(env []string) (out []string) {
for _, e := range env {
// Filter out GITHUB envs and anything with token in it,
// especially GITHUB_TOKEN in CI as it breaks TestWasm.
if strings.HasPrefix(e, "GITHUB") || strings.Contains(e, "TOKEN") {
continue
}
out = append(out, e)
}
return out
}

func assertCloseStatus(exp websocket.StatusCode, err error) error {
if websocket.CloseStatus(err) == -1 {
return fmt.Errorf("expected websocket.CloseError: %T %v", err, err)
Expand Down

0 comments on commit f8c1853

Please sign in to comment.