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:
authorJaime Martinez <jmartinez@gitlab.com>2021-02-16 10:00:46 +0300
committerJaime Martinez <jmartinez@gitlab.com>2021-03-18 03:20:19 +0300
commit4f597a45e15283cdefa66792575a6da602376ba2 (patch)
tree2d9a0791db7e196de4ed5eab94e5713cdeaaceac
parented2b1232009f50b54278cadae8c1a3659539fa4c (diff)
Simplify mock
-rw-r--r--internal/source/gitlab/cache/entry_test.go37
1 files changed, 15 insertions, 22 deletions
diff --git a/internal/source/gitlab/cache/entry_test.go b/internal/source/gitlab/cache/entry_test.go
index 59183785..528f2a6f 100644
--- a/internal/source/gitlab/cache/entry_test.go
+++ b/internal/source/gitlab/cache/entry_test.go
@@ -7,10 +7,9 @@ import (
"testing"
"time"
- "gitlab.com/gitlab-org/gitlab-pages/internal/domain"
-
"github.com/stretchr/testify/require"
+ "gitlab.com/gitlab-org/gitlab-pages/internal/domain"
"gitlab.com/gitlab-org/gitlab-pages/internal/source/gitlab/api"
)
@@ -116,7 +115,7 @@ func TestEntryRefresh(t *testing.T) {
require.Equal(t, storedEntry.Lookup(), entry.Lookup(), "lookup should be the same")
})
- t.Run("entry is different after expiring", func(t *testing.T) {
+ t.Run("entry is different after it expired and calling refresh on it", func(t *testing.T) {
client.failed = false
entry := newCacheEntry("error.gitlab.io", cc.entryRefreshTimeout, cc.cacheExpiry, store.(*memstore).retriever)
@@ -164,28 +163,22 @@ func (mm *lookupMock) GetLookup(ctx context.Context, domainName string) api.Look
Name: domainName,
}
- select {
- case <-ctx.Done():
- lookup.Error = ctx.Err()
+ lookup, ok := mm.responses[domainName]
+ if !ok {
+ lookup.Error = domain.ErrDomainDoesNotExist
return lookup
- default:
- lookup, ok := mm.responses[domainName]
- if !ok {
- lookup.Error = domain.ErrDomainDoesNotExist
- return lookup
- }
-
- // return error after mm.successCount
- mm.currentCount++
- if mm.currentCount > mm.successCount {
- mm.currentCount = 0
- mm.failed = true
-
- lookup.Error = http.ErrServerClosed
- }
+ }
- return lookup
+ // return error after mm.successCount
+ mm.currentCount++
+ if mm.currentCount > mm.successCount {
+ mm.currentCount = 0
+ mm.failed = true
+
+ lookup.Error = http.ErrServerClosed
}
+
+ return lookup
}
func (mm *lookupMock) Status() error {