Skip to content

Commit 1f60f82

Browse files
committed
Add NewBuildServiceClient unit tests
1 parent 6fb157b commit 1f60f82

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

maint/client_test.go

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"fmt"
77
"io"
88
"net/http"
9+
"net/url"
910
"sort"
1011
"testing"
1112

@@ -75,6 +76,47 @@ func createMockClient(baseUrl string, archs []string, forceError bool) *http.Cli
7576
}
7677
}
7778

79+
func TestNewBuildServiceClient(t *testing.T) {
80+
tests := []struct {
81+
name string
82+
buildservice string
83+
want *BuildServiceClient
84+
wantErr bool
85+
}{
86+
{
87+
"IBS client", "ibs",
88+
&BuildServiceClient{
89+
downloadLink: downloadIBSLink,
90+
baseURL: &url.URL{Host: ibsAPI, Scheme: "https"},
91+
},
92+
false,
93+
},
94+
{
95+
"OBS client", "obs",
96+
&BuildServiceClient{
97+
downloadLink: downloadOBSLink,
98+
baseURL: &url.URL{Host: obsAPI, Scheme: "https"},
99+
},
100+
false,
101+
},
102+
{
103+
"Invalid client", "github",
104+
nil,
105+
true,
106+
},
107+
}
108+
for _, tt := range tests {
109+
t.Run(tt.name, func(t *testing.T) {
110+
got, err := NewBuildServiceClient(BuildService(tt.buildservice), "test", "test")
111+
assert.EqualValues(t, tt.wantErr, (err != nil))
112+
if tt.want != nil {
113+
assert.EqualValues(t, tt.want.downloadLink, got.downloadLink)
114+
assert.EqualValues(t, tt.want.baseURL, got.baseURL)
115+
}
116+
})
117+
}
118+
}
119+
78120
func TestArchMage(t *testing.T) {
79121
maint := "http://download.suse.de/ibs/SUSE:/Maintenance:/1/"
80122

0 commit comments

Comments
 (0)