jsonapi/examples/fixtures.go

67 lines
939 B
Go
Raw Permalink Normal View History

package main
import "time"
func fixtureBlogCreate(i int) *Blog {
return &Blog{
ID: 1 * i,
Title: "Title 1",
CreatedAt: time.Now(),
Posts: []*Post{
2017-09-13 15:59:59 -04:00
{
ID: 1 * i,
Title: "Foo",
Body: "Bar",
Comments: []*Comment{
2017-09-13 15:59:59 -04:00
{
ID: 1 * i,
Body: "foo",
},
2017-09-13 15:59:59 -04:00
{
ID: 2 * i,
Body: "bar",
},
},
},
2017-09-13 15:59:59 -04:00
{
ID: 2 * i,
Title: "Fuubar",
Body: "Bas",
Comments: []*Comment{
2017-09-13 15:59:59 -04:00
{
ID: 1 * i,
Body: "foo",
},
2017-09-13 15:59:59 -04:00
{
ID: 3 * i,
Body: "bas",
},
},
},
},
CurrentPost: &Post{
ID: 1 * i,
Title: "Foo",
Body: "Bar",
Comments: []*Comment{
2017-09-13 15:59:59 -04:00
{
ID: 1 * i,
Body: "foo",
},
2017-09-13 15:59:59 -04:00
{
ID: 2 * i,
Body: "bar",
},
},
},
}
}
func fixtureBlogsList() (blogs []interface{}) {
for i := 0; i < 10; i++ {
blogs = append(blogs, fixtureBlogCreate(i))
}
return blogs
}