Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfeistel <6742251-feistel@users.noreply.gitlab.com>2022-02-11 20:38:21 +0300
committerfeistel <6742251-feistel@users.noreply.gitlab.com>2022-04-13 23:17:54 +0300
commitc9063fd0613ad4aac56b02f6feb5f2b1d9b019a3 (patch)
treef517433dbf5a550b655dfb8624c7bbd05853e6f5 /internal
parentc3b2e1e9d6586b138398deada33943956c51bf46 (diff)
test: simplify cache test for ctx errors
Diffstat (limited to 'internal')
-rw-r--r--internal/source/gitlab/cache/cache_test.go15
1 files changed, 4 insertions, 11 deletions
diff --git a/internal/source/gitlab/cache/cache_test.go b/internal/source/gitlab/cache/cache_test.go
index b92aa617..aad357ae 100644
--- a/internal/source/gitlab/cache/cache_test.go
+++ b/internal/source/gitlab/cache/cache_test.go
@@ -107,17 +107,10 @@ func TestResolve(t *testing.T) {
withTestCache(resolverConfig{bufferSize: 1}, cc, func(cache *Cache, resolver *clientMock) {
require.Equal(t, 0, len(resolver.lookups))
- go func() {
- lookup := cache.Resolve(context.Background(), "foo.gitlab.com")
- require.ErrorIs(t, lookup.Error, context.DeadlineExceeded)
- require.Equal(t, "foo.gitlab.com", lookup.Name)
- }()
-
- // wait for retrieval timeout to expire, then send a response to the retriever
- time.Sleep(2 * time.Second)
-
- // the ctx should be expired and the goroutine should receive an error
- resolver.domain <- "foo.gitlab.com"
+ // wait for retrieval timeout to expire
+ lookup := cache.Resolve(context.Background(), "foo.gitlab.com")
+ require.ErrorIs(t, lookup.Error, context.DeadlineExceeded)
+ require.Equal(t, "foo.gitlab.com", lookup.Name)
// future lookups should succeed once the entry has been refreshed.
// refresh happens in a separate goroutine so the first few requests might still fail