forked from concourse/github-release-resource
-
Notifications
You must be signed in to change notification settings - Fork 0
/
resource_suite_test.go
94 lines (83 loc) · 2.75 KB
/
resource_suite_test.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package resource_test
import (
"strconv"
"testing"
"time"
"github.com/concourse/github-release-resource"
"github.com/google/go-github/v39/github"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
func TestGithubReleaseResource(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Github Release Resource Suite")
}
func newRepositoryRelease(id int, version string) *github.RepositoryRelease {
return &github.RepositoryRelease{
TagName: github.String(version),
Draft: github.Bool(false),
Prerelease: github.Bool(false),
ID: github.Int64(int64(id)),
}
}
func newPreReleaseRepositoryRelease(id int, version string) *github.RepositoryRelease {
return &github.RepositoryRelease{
TagName: github.String(version),
Draft: github.Bool(false),
Prerelease: github.Bool(true),
ID: github.Int64(int64(id)),
}
}
func newDraftRepositoryRelease(id int, version string) *github.RepositoryRelease {
return &github.RepositoryRelease{
TagName: github.String(version),
Draft: github.Bool(true),
Prerelease: github.Bool(false),
ID: github.Int64(int64(id)),
}
}
func newDraftWithNilTagRepositoryRelease(id int) *github.RepositoryRelease {
return &github.RepositoryRelease{
Draft: github.Bool(true),
Prerelease: github.Bool(false),
ID: github.Int64(int64(id)),
}
}
func exampleTimeStamp(day int) time.Time {
return time.Date(2018, time.January, day, 0, 0, 0, 0, time.UTC)
}
func newRepositoryReleaseWithCreatedTime(id int, version string, day int) *github.RepositoryRelease {
return &github.RepositoryRelease{
TagName: github.String(version),
Draft: github.Bool(false),
Prerelease: github.Bool(false),
ID: github.Int64(int64(id)),
CreatedAt: &github.Timestamp{exampleTimeStamp(day)},
}
}
func newRepositoryReleaseWithPublishedTime(id int, version string, day int) *github.RepositoryRelease {
return &github.RepositoryRelease{
TagName: github.String(version),
Draft: github.Bool(false),
Prerelease: github.Bool(false),
ID: github.Int64(int64(id)),
PublishedAt: &github.Timestamp{exampleTimeStamp(day)},
}
}
func newRepositoryReleaseWithCreatedAndPublishedTime(id int, version string, createdDay int, publishedDay int) *github.RepositoryRelease {
return &github.RepositoryRelease{
TagName: github.String(version),
Draft: github.Bool(false),
Prerelease: github.Bool(false),
ID: github.Int64(int64(id)),
CreatedAt: &github.Timestamp{exampleTimeStamp(createdDay)},
PublishedAt: &github.Timestamp{exampleTimeStamp(publishedDay)},
}
}
func newVersionWithTimestamp(id int, tag string, day int) resource.Version {
return resource.Version{
ID: strconv.Itoa(id),
Tag: tag,
Timestamp: exampleTimeStamp(day),
}
}