forked from shuheiktgw/go-travis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
beta_features_integration_test.go
88 lines (65 loc) · 2.33 KB
/
beta_features_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
// 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"
"time"
)
const integrationBetaFeatureId = 1
func TestBetaFeaturesService_Integration_List(t *testing.T) {
_, res, err := integrationClient.BetaFeatures.List(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)
}
}
func TestBetaFeaturesService_Integration_Update(t *testing.T) {
feature, res, err := integrationClient.BetaFeatures.Update(context.TODO(), integrationUserId, integrationBetaFeatureId, true)
if err != nil {
t.Fatalf("unexpected error occured: %s", err)
}
if res.StatusCode != http.StatusOK {
t.Fatalf("invalid http status: %s", res.Status)
}
if *feature.Id != integrationBetaFeatureId || *feature.Enabled != true {
t.Fatalf("unexpected beta feature has returned: %v", feature)
}
time.Sleep(2 * time.Second)
feature, res, err = integrationClient.BetaFeatures.Update(context.TODO(), integrationUserId, integrationBetaFeatureId, false)
if err != nil {
t.Fatalf("unexpected error occured: %s", err)
}
if res.StatusCode != http.StatusOK {
t.Fatalf("invalid http status: %s", res.Status)
}
if *feature.Id != integrationBetaFeatureId || *feature.Enabled != false {
t.Fatalf("unexpected beta feature has returned: %v", feature)
}
}
func TestBetaFeaturesService_Integration_Delete(t *testing.T) {
// Need to enable the feature before deleting it
_, res, err := integrationClient.BetaFeatures.Update(context.TODO(), integrationUserId, integrationBetaFeatureId, true)
if err != nil {
t.Fatalf("unexpected error occured: %s", err)
}
if res.StatusCode != http.StatusOK {
t.Fatalf("invalid http status: %s", res.Status)
}
f, res, err := integrationClient.BetaFeatures.Delete(context.TODO(), integrationUserId, integrationBetaFeatureId)
if err != nil {
t.Fatalf("unexpected error occured: %s", err)
}
if res.StatusCode != http.StatusOK {
t.Fatalf("invalid http status: %s", res.Status)
}
if got, want := int(*f.Id), integrationBetaFeatureId; got != want {
t.Fatalf("invalid beta feature id: got %d, want: %d", got, want)
}
}