diff options
Diffstat (limited to 'internal/cache/domain/domain_test.go')
-rw-r--r-- | internal/cache/domain/domain_test.go | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/internal/cache/domain/domain_test.go b/internal/cache/domain/domain_test.go index 9e091e1d0..974425b7c 100644 --- a/internal/cache/domain/domain_test.go +++ b/internal/cache/domain/domain_test.go @@ -28,9 +28,13 @@ func TestCache(t *testing.T) { c := new(domain.Cache) cachedDomains := []string{ - "google.com", - "google.co.uk", - "pleroma.bad.host", + "google.com", // + "mail.google.com", // should be ignored since covered above + "dev.mail.google.com", // same again + "google.co.uk", // + "mail.google.co.uk", // + "pleroma.bad.host", // + "pleroma.still.a.bad.host", // } loader := func() ([]string, error) { @@ -38,22 +42,25 @@ func TestCache(t *testing.T) { return cachedDomains, nil } - // Check a list of known cached domains. + // Check a list of known matching domains. for _, domain := range []string{ "google.com", "mail.google.com", + "dev.mail.google.com", "google.co.uk", "mail.google.co.uk", "pleroma.bad.host", "dev.pleroma.bad.host", + "pleroma.still.a.bad.host", + "dev.pleroma.still.a.bad.host", } { t.Logf("checking domain matches: %s", domain) if b, _ := c.Matches(domain, loader); !b { - t.Errorf("domain should be matched: %s", domain) + t.Fatalf("domain should be matched: %s", domain) } } - // Check a list of known uncached domains. + // Check a list of known unmatched domains. for _, domain := range []string{ "askjeeves.com", "ask-kim.co.uk", @@ -61,10 +68,11 @@ func TestCache(t *testing.T) { "mail.google.ie", "gts.bad.host", "mastodon.bad.host", + "akkoma.still.a.bad.host", } { t.Logf("checking domain isn't matched: %s", domain) if b, _ := c.Matches(domain, loader); b { - t.Errorf("domain should not be matched: %s", domain) + t.Fatalf("domain should not be matched: %s", domain) } } @@ -80,6 +88,6 @@ func TestCache(t *testing.T) { t.Log("load: returning known error") return nil, knownErr }); !errors.Is(err, knownErr) { - t.Errorf("matches did not return expected error: %v", err) + t.Fatalf("matches did not return expected error: %v", err) } } |