forked from go-vela/types
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_package_test.go
85 lines (63 loc) · 1.62 KB
/
build_package_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
// Copyright (c) 2022 Target Brands, Inc. All rights reserved.
//
// Use of this source code is governed by the LICENSE file in this repository.
package types
import (
"reflect"
"testing"
"github.com/go-vela/types/library"
"github.com/go-vela/types/pipeline"
)
func TestBuildPackage_WithBuild(t *testing.T) {
id := int64(1)
b := &library.Build{ID: &id}
want := new(BuildPackage)
want.Build = b
// run test
got := new(BuildPackage)
if !reflect.DeepEqual(got.WithBuild(b), want) {
t.Errorf("WithBuild is %v, want %v", got, want)
}
}
func TestBuildPackage_WithPipeline(t *testing.T) {
id := "build"
p := &pipeline.Build{ID: id}
want := new(BuildPackage)
want.Pipeline = p
// run test
got := new(BuildPackage)
if !reflect.DeepEqual(got.WithPipeline(p), want) {
t.Errorf("WithPipeline is %v, want %v", got, want)
}
}
func TestBuildPackage_WithRepo(t *testing.T) {
id := int64(1)
r := &library.Repo{ID: &id}
want := new(BuildPackage)
want.Repo = r
// run test
got := new(BuildPackage)
if !reflect.DeepEqual(got.WithRepo(r), want) {
t.Errorf("WithRepo is %v, want %v", got, want)
}
}
func TestBuildPackage_WithUser(t *testing.T) {
id := int64(1)
u := &library.User{ID: &id}
want := new(BuildPackage)
want.User = u
// run test
got := new(BuildPackage)
if !reflect.DeepEqual(got.WithUser(u), want) {
t.Errorf("WithUser is %v, want %v", got, want)
}
}
func TestBuildPackage_WithToken(t *testing.T) {
want := new(BuildPackage)
want.Token = "123abc"
// run test
got := new(BuildPackage)
if !reflect.DeepEqual(got.WithToken("123abc"), want) {
t.Errorf("WithToken is %v, want %v", got, want)
}
}