-
Notifications
You must be signed in to change notification settings - Fork 0
/
fixtures.go
72 lines (65 loc) · 1.87 KB
/
fixtures.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package mytest
import (
"fmt"
"github.com/xbc5/sumo/internal/pkg/database/dbmod"
)
func FakePattern(suffix uint, pattern string, tags []string) dbmod.Pattern {
return dbmod.ToPattern(
fmt.Sprintf("Fake pattern %d name", suffix),
fmt.Sprintf("Fake pattern %d description", suffix),
pattern,
tags,
)
}
func FakeAuthors(names []string) []dbmod.Author {
authors := []dbmod.Author{}
for _, name := range names {
authors = append(authors, dbmod.Author{
Name: name,
})
}
return authors
}
func FakeAttachments(num uint) []dbmod.Attachment {
atch := []dbmod.Attachment{}
for i := 0; 0 < num; i++ {
atch = append(atch, dbmod.Attachment{
URL: fmt.Sprintf("https://feedexample.com/attachment%d", i),
Length: 1234, // who cares?
Type: "fake/type",
})
}
return atch
}
func FakeArticle(
suffix uint,
tags []string,
authors []dbmod.Author,
published uint64,
modified uint64,
attachments []dbmod.Attachment,
) dbmod.Article {
return dbmod.Article{
URL: fmt.Sprintf("https://fakefeed.com/article%d", suffix),
Title: fmt.Sprintf("Fake Article Title %d", suffix),
Description: fmt.Sprintf("Fake article description %d", suffix),
Content: fmt.Sprintf("Fake article content %d", suffix),
PublishedAt: published,
ModifiedAt: modified,
Banner: fmt.Sprintf("https://fakefeed.com/banner%d.jpg", suffix),
Authors: authors,
Attachments: attachments,
Tags: dbmod.ToTags(tags),
}
}
func FakeFeed(suffix uint, tags []string, articles []dbmod.Article) dbmod.Feed {
return dbmod.Feed{
URL: fmt.Sprintf("https://fakefeed%d.com/", suffix),
Title: fmt.Sprintf("Fake Feed Title %d", suffix),
Description: fmt.Sprintf("Fake feed description %d", suffix),
Language: "en_gb",
Logo: fmt.Sprintf("https://fakefeed%d.com/logo.ico", suffix),
Articles: articles,
Tags: dbmod.ToTags(tags),
}
}