forked from Ableton/go-travis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
builds_integration_test.go
107 lines (84 loc) · 2.43 KB
/
builds_integration_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
95
96
97
98
99
100
101
102
103
104
105
106
107
// Copyright (c) 2015 Ableton AG, Berlin. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build integration
package travis
import "testing"
func TestBuildsService_List_without_options(t *testing.T) {
t.Parallel()
builds, _, _, _, err := integrationClient.Builds.List(nil)
ok(t, err)
assert(
t,
len(builds) > 0,
"Builds.List returned no builds",
)
}
func TestBuildsService_List_with_options(t *testing.T) {
t.Parallel()
slug := integrationRepo
number := "1"
opt := &BuildListOptions{Slug: slug, Number: number}
builds, _, _, _, err := integrationClient.Builds.List(opt)
ok(t, err)
assert(
t,
len(builds) == 1,
"Builds.List returned no builds",
)
// Weirdly, the returned payload does not contained the slug
// you are filtering on...
// assert(
// t,
// builds[0].Slug == slug,
// "Builds.List first returned build instance Slug = %s; expected %s", builds[0].Slug, slug,
// )
assert(
t,
builds[0].Number == "1",
"Builds.List first returned build instance Number = %s; expected %s", builds[0].Number, number,
)
}
func TestBuildsService_ListFromRepository_without_options(t *testing.T) {
t.Parallel()
_, _, _, _, err := integrationClient.Builds.ListFromRepository(integrationRepo, nil)
ok(t, err)
}
func TestBuildsService_ListFromRepository_with_options(t *testing.T) {
t.Parallel()
opt := &BuildListOptions{EventType: "push"}
builds, _, _, _, err := integrationClient.Builds.ListFromRepository(integrationRepo, opt)
ok(t, err)
if builds != nil {
for _, b := range builds {
assert(
t,
b.EventType == "push",
"Builds.ListFromRepository returned builds with EventType != push",
)
}
}
}
func TestBuildsService_Get(t *testing.T) {
t.Parallel()
// Fetch the reference repository first build in order
// to have an existing build id to test against
builds, _, _, _, err := integrationClient.Builds.ListFromRepository(integrationRepo, &BuildListOptions{Number: "1"})
if builds == nil || len(builds) == 0 {
t.Skip("No builds found for the provided integration repo. skipping test")
}
buildId := builds[0].Id
build, _, _, _, err := integrationClient.Builds.Get(buildId)
ok(t, err)
assert(
t,
build.Id == buildId,
"Builds.Get return build with Id %d; expected %d", build.Id, buildId,
)
assert(
t,
build.Number == "1",
"Builds.Get return build with Number %s; expected %s", build.Number, "1",
)
}