This repository has been archived by the owner on Jan 21, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
users_integration_test.go
79 lines (62 loc) · 1.69 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
// 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"
"time"
)
func TestUsersService_GetAuthenticated(t *testing.T) {
t.Parallel()
if auth := integrationClient.IsAuthenticated(); !auth {
t.Skip("test client is unauthenticated. skipping.")
}
user, _, err := integrationClient.Users.GetAuthenticated()
ok(t, err)
assert(
t,
user != nil,
"UsersService.GetAuthenticated returned nil user",
)
}
func TestUsersService_Get(t *testing.T) {
t.Parallel()
if auth := integrationClient.IsAuthenticated(); !auth {
t.Skip("test client is unauthenticated. skipping.")
}
authenticatedUser, _, err := integrationClient.Users.GetAuthenticated()
userId := authenticatedUser.Id
user, _, err := integrationClient.Users.Get(userId)
ok(t, err)
assert(
t,
authenticatedUser != nil,
"UsersService.Get returned nil user",
)
assert(
t,
user.Id == userId,
"UsersService.Get returned user with id %d; expected %d", user.Id, userId,
)
}
func TestUsersService_Sync(t *testing.T) {
t.Parallel()
if auth := integrationClient.IsAuthenticated(); !auth {
t.Skip("test client is unauthenticated. skipping.")
}
userNow, _, err := integrationClient.Users.GetAuthenticated()
_, err = integrationClient.Users.Sync()
ok(t, err)
time.Sleep(5 * time.Second)
userThen, _, err := integrationClient.Users.GetAuthenticated()
if userThen != nil {
// User might have been destroyed since last sync
assert(
t,
userThen.SyncedAt > userNow.SyncedAt,
"UsersService.Sync does not have updated the user synced_at marker",
)
}
}