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 pathpreferences_integration_test.go
111 lines (88 loc) · 3.34 KB
/
preferences_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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
// 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"
"reflect"
"testing"
)
const integrationPreferenceName = "build_emails"
func TestPreferencesService_Integration_Find(t *testing.T) {
preference, res, err := integrationClient.Preferences.Find(context.TODO(), integrationPreferenceName)
if err != nil {
t.Fatalf("Preference.Find unexpected error occured: %s", err)
}
if res.StatusCode != http.StatusOK {
t.Fatalf("Preference.Find invalid http status: %s", res.Status)
}
want := &Preference{
Name: String(integrationPreferenceName),
Value: true,
Metadata: &Metadata{Type: String("preference"), Href: String("/v3/preference/build_emails"), Representation: String("standard")},
}
if !reflect.DeepEqual(preference, want) {
t.Errorf("Preference.Find returned %+v, want %+v", preference, want)
}
}
func TestPreferencesService_Integration_List(t *testing.T) {
preferences, res, err := integrationClient.Preferences.List(context.TODO())
if err != nil {
t.Fatalf("Preferences.List unexpected error occured: %s", err)
}
if res.StatusCode != http.StatusOK {
t.Fatalf("Preferences.List invalid http status: %s", res.Status)
}
want := []*Preference{
{
Name: String("build_emails"),
Value: true,
Metadata: &Metadata{Type: String("preference"), Href: String("/v3/preference/build_emails"), Representation: String("standard")},
},
{
Name: String("private_insights_visibility"),
Value: "private",
Metadata: &Metadata{Type: String("preference"), Href: String("/v3/preference/private_insights_visibility"), Representation: String("standard")},
},
}
if !reflect.DeepEqual(preferences, want) {
t.Errorf("Preferences.Find returned %+v, want %+v", preferences, want)
}
}
func TestPreferenceServices_Integration_Update(t *testing.T) {
// Change build_emails = false
preference, res, err := integrationClient.Preferences.Update(context.TODO(), &PreferenceBody{Name: integrationPreferenceName, Value: false})
if err != nil {
t.Fatalf("Preference.Update unexpected error occured: %s", err)
}
if res.StatusCode != http.StatusOK {
t.Fatalf("Preference.Update invalid http status: %s", res.Status)
}
want := &Preference{
Name: String(integrationPreferenceName),
Value: false,
Metadata: &Metadata{Type: String("preference"), Href: String("/v3/preference/build_emails"), Representation: String("standard")},
}
if !reflect.DeepEqual(preference, want) {
t.Errorf("Preference.Update returned %+v, want %+v", preference, want)
}
// Change build_emails = true
preference, res, err = integrationClient.Preferences.Update(context.TODO(), &PreferenceBody{Name: integrationPreferenceName, Value: true})
if err != nil {
t.Fatalf("Preference.Update unexpected error occured: %s", err)
}
if res.StatusCode != http.StatusOK {
t.Fatalf("Preference.Update invalid http status: %s", res.Status)
}
want = &Preference{
Name: String(integrationPreferenceName),
Value: true,
Metadata: &Metadata{Type: String("preference"), Href: String("/v3/preference/build_emails"), Representation: String("standard")},
}
if !reflect.DeepEqual(preference, want) {
t.Errorf("Preference.Update returned %+v, want %+v", preference, want)
}
}