changing layout
This commit is contained in:
parent
17b5f751e2
commit
b1c6aa659b
37 changed files with 695 additions and 1018 deletions
|
|
@ -1,12 +1,18 @@
|
|||
package persistence
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/example/cms/internal/domain"
|
||||
)
|
||||
|
||||
func TestModelsUseMigrationTableNames(t *testing.T) {
|
||||
tests := map[string]string{
|
||||
"users": (UserModel{}).TableName(),
|
||||
"admins": (AdminModel{}).TableName(),
|
||||
"sessions": (SessionModel{}).TableName(),
|
||||
"content": (ContentModel{}).TableName(),
|
||||
"content_history": (ContentHistoryModel{}).TableName(),
|
||||
"categories": (CategoryModel{}).TableName(),
|
||||
"badges": (BadgeModel{}).TableName(),
|
||||
}
|
||||
for expected, actual := range tests {
|
||||
if actual != expected {
|
||||
|
|
@ -14,3 +20,11 @@ func TestModelsUseMigrationTableNames(t *testing.T) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestContentMappingRoundTrip(t *testing.T) {
|
||||
d := domain.Content{ID: 2, Slug: "hello-world", Title: "Hello", Body: "body", Status: "draft", Badges: []string{"go"}, CreatedAt: time.Now()}
|
||||
got := ContentToDomain(ContentFromDomain(d))
|
||||
if got.Slug != d.Slug || got.Title != d.Title || got.Status != d.Status {
|
||||
t.Fatalf("round trip mismatch: %+v", got)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue