🎨 Used special domains in test objects
/ docker (push) Successful in 1m53s Details

See https://datatracker.ietf.org/doc/html/rfc6761#section-6.2
This commit is contained in:
Maxim Lebedev 2024-02-17 00:30:24 +06:00
parent 326b7a478a
commit 4730b7074f
Signed by: toby3d
GPG Key ID: 1F14E25B7C119FC5
3 changed files with 12 additions and 10 deletions

View File

@ -43,7 +43,7 @@ func TestSite(tb testing.TB) *Site {
DefaultLanguage: en, DefaultLanguage: en,
Language: ru, Language: ru,
Languages: []Language{en, ru}, Languages: []Language{en, ru},
BaseURL: &url.URL{Scheme: "https", Host: "example.com", Path: "/"}, BaseURL: &url.URL{Scheme: "https", Host: "test.web.site", Path: "/"},
TimeZone: time.UTC, TimeZone: time.UTC,
File: NewPath(filepath.Join("content", "index.en.md")), File: NewPath(filepath.Join("content", "index.en.md")),
Title: "Testing", Title: "Testing",
@ -76,8 +76,8 @@ func TestSite(tb testing.TB) *Site {
"headers": []any{map[string]any{ "headers": []any{map[string]any{
"path": "/**", "path": "/**",
"values": map[string]any{ "values": map[string]any{
"Link": `<https://auth.example.com/>; rel="indieauth-metadata", ` + "Link": `<https://test.auth.app/>; rel="indieauth-metadata", ` +
`<https://pub.example.com/>; rel="micropub"`, `<https://test.pub.app/>; rel="micropub"`,
"X-Koroko": "Ya-ha-ha!", "X-Koroko": "Ya-ha-ha!",
}, },
}, map[string]any{ }, map[string]any{
@ -92,7 +92,7 @@ func TestSite(tb testing.TB) *Site {
"status": 302, "status": 302,
}, map[string]any{ }, map[string]any{
"from": "/foo", "from": "/foo",
"to": "https://example.com/", "to": "https://test.redirect.site/",
"status": 301, "status": 301,
"force": true, "force": true,
}}, }},

View File

@ -8,14 +8,16 @@ import (
"source.toby3d.me/toby3d/home/internal/domain" "source.toby3d.me/toby3d/home/internal/domain"
"source.toby3d.me/toby3d/home/internal/server/usecase" "source.toby3d.me/toby3d/home/internal/server/usecase"
"source.toby3d.me/toby3d/home/internal/site/repository/stub"
) )
func TestDo(t *testing.T) { func TestDo(t *testing.T) {
t.Parallel() t.Parallel()
site := domain.TestSite(t) testSite := domain.TestSite(t)
actual, err := usecase.NewServerUseCase().Do(context.Background(), site) actual, err := usecase.NewServerUseCase(stub.NewStubSiteRepository(testSite, nil)).
Do(context.Background(), testSite.Language)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -24,8 +26,8 @@ func TestDo(t *testing.T) {
Headers: []domain.Header{{ Headers: []domain.Header{{
Path: "/**", Path: "/**",
Values: map[string]string{ Values: map[string]string{
"Link": `<https://auth.example.com/>; rel="indieauth-metadata", ` + "Link": `<https://test.auth.app/>; rel="indieauth-metadata", ` +
`<https://pub.example.com/>; rel="micropub"`, `<https://test.pub.app/>; rel="micropub"`,
"X-Koroko": "Ya-ha-ha!", "X-Koroko": "Ya-ha-ha!",
}, },
}, { }, {
@ -41,7 +43,7 @@ func TestDo(t *testing.T) {
Force: false, Force: false,
}, { }, {
From: "/foo", From: "/foo",
To: "https://example.com/", To: "https://test.redirect.site/",
Status: 301, Status: 301,
Force: true, Force: true,
}}, }},

View File

@ -1 +1 @@
{"subject":"acct:user@example.com","links":[{"rel":"self","type":"application/activity+json","href":"https://example.com/"},{"rel":"http://webfinger.net/rel/profile-page","type":"text/html","href":"https://example.com/"},{"rel":"http://webfinger.net/rel/avatar","type":"image/jpeg","href":"https://example.com/logo.jpg"}]} {"subject":"acct:user@test.web.site","links":[{"rel":"self","type":"application/activity+json","href":"https://test.web.site/"},{"rel":"http://webfinger.net/rel/profile-page","type":"text/html","href":"https://test.web.site/"},{"rel":"http://webfinger.net/rel/avatar","type":"image/jpeg","href":"https://test.web.site/"}]}