client/web: fix data race

Fixes #9150

Signed-off-by: Maisem Ali <maisem@tailscale.com>
This commit is contained in:
Maisem Ali 2023-08-29 18:50:04 -07:00 committed by Maisem Ali
parent 7538f38671
commit b90b9b4653
1 changed files with 6 additions and 10 deletions

View File

@ -77,17 +77,13 @@ func TestQnapAuthnURL(t *testing.T) {
func TestServeAPI(t *testing.T) {
lal := memnet.Listen("local-tailscaled.sock:80")
defer lal.Close()
// Serve dummy localapi. Just returns "success".
go func() {
localapi := &http.Server{Handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "success")
})}
defer localapi.Close()
if err := localapi.Serve(lal); err != nil {
t.Error(err)
}
}()
localapi := &http.Server{Handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "success")
})}
defer localapi.Close()
go localapi.Serve(lal)
s := &Server{lc: &tailscale.LocalClient{Dial: lal.Dial}}
tests := []struct {