This repository has been archived by the owner on Feb 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
owners_test.go
60 lines (48 loc) · 1.75 KB
/
owners_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
// 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.
package travis
import (
"context"
"fmt"
"net/http"
"reflect"
"testing"
)
func TestOwnerService_FindByLogin(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()
mux.HandleFunc("/owner/shuheiktgw", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, http.MethodGet)
testFormValues(t, r, values{"include": "owner.repositories"})
fmt.Fprint(w, `{"id":1,"login":"shuheiktgw","github_id":1}`)
})
opt := OwnerOption{Include: []string{"owner.repositories"}}
owner, _, err := client.Owner.FindByLogin(context.Background(), "shuheiktgw", &opt)
if err != nil {
t.Errorf("Owner.FindByLogin returned error: %v", err)
}
want := &Owner{Id: Uint(1), Login: String("shuheiktgw"), GitHubId: Uint(1)}
if !reflect.DeepEqual(owner, want) {
t.Errorf("Owner.FindByLogin returned %+v, want %+v", owner, want)
}
}
func TestOwnerService_FindByGitHubId(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()
mux.HandleFunc("/owner/github_id/1", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, http.MethodGet)
testFormValues(t, r, values{"include": "owner.installation"})
fmt.Fprint(w, `{"id":1,"login":"shuheiktgw","github_id":1}`)
})
opt := OwnerOption{Include: []string{"owner.installation"}}
owner, _, err := client.Owner.FindByGitHubId(context.Background(), 1, &opt)
if err != nil {
t.Errorf("Owner.FindByGitHubId returned error: %v", err)
}
want := &Owner{Id: Uint(1), Login: String("shuheiktgw"), GitHubId: Uint(1)}
if !reflect.DeepEqual(owner, want) {
t.Errorf("Owner.FindByGitHubId returned %+v, want %+v", owner, want)
}
}