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
/
Copy pathusers_integration_test.go
80 lines (61 loc) · 2.04 KB
/
users_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
// 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 (
"context"
"net/http"
"testing"
)
func TestUserService_Integration_Current(t *testing.T) {
opt := UserOption{Include: []string{"user.repositories", "user.installation", "user.emails"}}
user, res, err := integrationClient.User.Current(context.TODO(), &opt)
if err != nil {
t.Fatalf("unexpected error occured: %s", err)
}
if res.StatusCode != http.StatusOK {
t.Fatalf("invalid http status: %s", res.Status)
}
if *user.Id != integrationUserId {
t.Fatalf("unexpected user returned: want user_id: %d, got user_id %d", integrationUserId, user.Id)
}
if !user.Repositories[0].IsStandard() {
t.Fatal("repository is not in a standard representation")
}
if len(user.Emails) == 0 {
t.Fatal("emails are empty")
}
}
func TestUserService_Integration_Find(t *testing.T) {
opt := UserOption{Include: []string{"user.repositories", "user.installation", "user.emails"}}
user, res, err := integrationClient.User.Find(context.TODO(), integrationUserId, &opt)
if err != nil {
t.Fatalf("unexpected error occured: %s", err)
}
if res.StatusCode != http.StatusOK {
t.Fatalf("invalid http status: %s", res.Status)
}
if *user.Id != integrationUserId {
t.Fatalf("unexpected user returned: want user_id: %d, got user_id %d", integrationUserId, user.Id)
}
if !user.Repositories[0].IsStandard() {
t.Fatal("repository is not in a standard representation")
}
if len(user.Emails) == 0 {
t.Fatal("emails are empty")
}
}
func TestUserService_Integration_Sync(t *testing.T) {
user, res, err := integrationClient.User.Sync(context.TODO(), integrationUserId)
if err != nil {
t.Fatalf("unexpected error occured: %s", err)
}
if res.StatusCode != http.StatusOK {
t.Fatalf("invalid http status: %s", res.Status)
}
if *user.Id != integrationUserId {
t.Fatalf("UserService.Find returned id %+v, want %+v", user.Id, integrationUserId)
}
}