fix flaky tests

This commit is contained in:
Umputun 2021-08-12 22:31:15 -05:00
parent 935e492461
commit d364904dd8
2 changed files with 5 additions and 2 deletions

View File

@ -252,6 +252,9 @@ func (s *Service) Mappers() (mappers []URLMapper) {
for _, m := range s.mappers {
mappers = append(mappers, m...)
}
sort.Slice(mappers, func(i, j int) bool {
return mappers[i].ProviderID < mappers[j].ProviderID
})
return mappers
}

View File

@ -109,7 +109,7 @@ func TestHttp_DoWithAssets(t *testing.T) {
cc := NewCacheControl(time.Hour * 12)
h := Http{Timeouts: Timeouts{ResponseHeader: 200 * time.Millisecond}, Address: fmt.Sprintf("127.0.0.1:%d", port),
AccessLog: io.Discard, AssetsWebRoot: "/static", AssetsLocation: "testdata", CacheControl: cc, Reporter: &ErrorReporter{Nice: false}}
ctx, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond)
ctx, cancel := context.WithTimeout(context.Background(), 1000*time.Millisecond)
defer cancel()
ds := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
@ -136,7 +136,7 @@ func TestHttp_DoWithAssets(t *testing.T) {
go func() {
_ = h.Run(ctx)
}()
time.Sleep(10 * time.Millisecond)
time.Sleep(50 * time.Millisecond)
client := http.Client{}