🧑💻 Added TestSite util for tests
This commit is contained in:
parent
5d3bd2e334
commit
c05feef09b
|
@ -3,6 +3,8 @@ package domain
|
|||
import (
|
||||
"net/url"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
@ -29,3 +31,37 @@ func (s Site) LanguagePrefix() string {
|
|||
func (s Site) IsMultiLingual() bool {
|
||||
return 1 < len(s.Languages)
|
||||
}
|
||||
|
||||
func TestSite(tb testing.TB) *Site {
|
||||
tb.Helper()
|
||||
|
||||
ru := NewLanguage("ru")
|
||||
en := NewLanguage("en")
|
||||
|
||||
return &Site{
|
||||
DefaultLanguage: en,
|
||||
Language: ru,
|
||||
Languages: []Language{en, ru},
|
||||
BaseURL: &url.URL{Scheme: "http", Host: "127.0.0.1:3000", Path: "/"},
|
||||
TimeZone: time.UTC,
|
||||
File: NewFile(filepath.Join("content", "index.en.md")),
|
||||
Title: "Testing",
|
||||
Resources: make([]*Resource, 0),
|
||||
Params: map[string]any{
|
||||
"server": map[string]any{
|
||||
"header": []any{map[string]any{
|
||||
"path": "/**",
|
||||
"headers": map[string]any{
|
||||
"Link": `<https://auth.example.com/>; rel="indieauth-metadata", ` +
|
||||
`<https://pub.example.com/>; rel="micropub"`,
|
||||
},
|
||||
}, map[string]any{
|
||||
"path": "/foo/bar",
|
||||
"headers": map[string]any{
|
||||
"X-Testing": `sample-text`,
|
||||
},
|
||||
}},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue