Fixed FileSystem repositoryes tests of Site and Page

This commit is contained in:
Maxim Lebedev 2023-11-13 05:26:59 +06:00
parent c9db0f0ce0
commit f3eca3dc73
Signed by: toby3d
GPG Key ID: 1F14E25B7C119FC5
2 changed files with 36 additions and 17 deletions

View File

@ -33,41 +33,46 @@ func TestGet(t *testing.T) {
"index": {
input: path.Join("index"),
expect: &domain.Page{
Content: []byte("index.md"),
Params: make(map[string]any),
Resources: make([]*domain.Resource, 0),
Content: []byte("index.md"),
Params: make(map[string]any),
Resources: make([]*domain.Resource, 0),
Translations: make([]*domain.Page, 0),
},
},
"file": {
input: path.Join("file"),
expect: &domain.Page{
Content: []byte("file.md"),
Params: make(map[string]any),
Resources: make([]*domain.Resource, 0),
Content: []byte("file.md"),
Params: make(map[string]any),
Resources: make([]*domain.Resource, 0),
Translations: make([]*domain.Page, 0),
},
},
"folder": {
input: path.Join("folder", "index"),
expect: &domain.Page{
Content: []byte("folder/index.md"),
Params: make(map[string]any),
Resources: make([]*domain.Resource, 0),
Content: []byte("folder/index.md"),
Params: make(map[string]any),
Resources: make([]*domain.Resource, 0),
Translations: make([]*domain.Page, 0),
},
},
"both-file": {
input: path.Join("both"),
expect: &domain.Page{
Content: []byte("both.md"),
Params: make(map[string]any),
Resources: make([]*domain.Resource, 0),
Content: []byte("both.md"),
Params: make(map[string]any),
Resources: make([]*domain.Resource, 0),
Translations: make([]*domain.Page, 0),
},
},
"both-folder": {
input: path.Join("both", "index"),
expect: &domain.Page{
Content: []byte("both/index.md"),
Params: make(map[string]any),
Resources: make([]*domain.Resource, 0),
Content: []byte("both/index.md"),
Params: make(map[string]any),
Resources: make([]*domain.Resource, 0),
Translations: make([]*domain.Page, 0),
},
},
} {
@ -81,7 +86,14 @@ func TestGet(t *testing.T) {
t.Fatal(err)
}
if diff := cmp.Diff(out, tc.expect, cmp.AllowUnexported(domain.File{}, domain.LanguageUnd)); diff != "" {
if diff := cmp.Diff(out, tc.expect, cmp.FilterPath(func(p cmp.Path) bool {
switch p.String() {
default:
return false
case "File", "Language":
return true
}
}, cmp.Ignore())); diff != "" {
t.Error(diff)
}
})

View File

@ -58,7 +58,14 @@ func TestGet(t *testing.T) {
t.Fatal(err)
}
if diff := cmp.Diff(out, tc.expect, cmp.AllowUnexported(domain.LanguageUnd, domain.File{})); diff != "" {
if diff := cmp.Diff(out, tc.expect, cmp.FilterPath(func(p cmp.Path) bool {
switch p.String() {
default:
return false
case "File", "Language":
return true
}
}, cmp.Ignore())); diff != "" {
t.Error(diff)
}
})