Fix race in tests (modifying already started server config) (#8227)

This commit is contained in:
Lucas Manuel Rodriguez 2022-10-14 12:00:16 -03:00 committed by GitHub
parent 06a9e886a1
commit 03096ee546
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -253,12 +253,13 @@ func RunServerForTestsWithDS(t *testing.T, ds fleet.Datastore, opts ...*TestServ
}
limitStore, _ := memstore.New(0)
r := MakeHandler(svc, cfg, logger, limitStore, WithLoginRateLimit(throttled.PerMin(100)))
server := httptest.NewServer(r)
server := httptest.NewUnstartedServer(r)
// Set the same ReadTimeout as the actual server
server.Config.ReadTimeout = 25 * time.Second
server.Start()
t.Cleanup(func() {
server.Close()
})
// Set the same ReadTimeout as the actual server
server.Config.ReadTimeout = 25 * time.Second
return users, server
}