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
/
caches_test.go
98 lines (76 loc) · 2.9 KB
/
caches_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
// 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 TestCachesService_ListByRepoId(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()
mux.HandleFunc(fmt.Sprintf("/repo/%d/caches", testRepoId), func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, http.MethodGet)
fmt.Fprint(w, `{"caches": [{"branch":"master","match":"test"}]}`)
})
caches, _, err := client.Caches.ListByRepoId(context.Background(), testRepoId)
if err != nil {
t.Errorf("Caches.FindByRepoId returned error: %v", err)
}
want := []*Cache{{Branch: String("master"), Match: String("test")}}
if !reflect.DeepEqual(caches, want) {
t.Errorf("Caches.FindByRepoId returned %+v, want %+v", caches, want)
}
}
func TestCachesService_ListByRepoSlug(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()
mux.HandleFunc(fmt.Sprintf("/repo/%s/caches", testRepoSlug), func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, http.MethodGet)
fmt.Fprint(w, `{"caches": [{"branch":"master","match":"test"}]}`)
})
caches, _, err := client.Caches.ListByRepoSlug(context.Background(), testRepoSlug)
if err != nil {
t.Errorf("Caches.FindByRepoSlug returned error: %v", err)
}
want := []*Cache{{Branch: String("master"), Match: String("test")}}
if !reflect.DeepEqual(caches, want) {
t.Errorf("Caches.FindByRepoSlug returned %+v, want %+v", caches, want)
}
}
func TestCachesService_DeleteByRepoId(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()
mux.HandleFunc(fmt.Sprintf("/repo/%d/caches", testRepoId), func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, http.MethodDelete)
fmt.Fprint(w, `{"caches": [{"branch":"master","match":"test"}]}`)
})
caches, _, err := client.Caches.DeleteByRepoId(context.Background(), testRepoId)
if err != nil {
t.Errorf("Caches.DeleteByRepoId returned error: %v", err)
}
want := []*Cache{{Branch: String("master"), Match: String("test")}}
if !reflect.DeepEqual(caches, want) {
t.Errorf("Caches.DeleteByRepoId returned %+v, want %+v", caches, want)
}
}
func TestCachesService_DeleteByRepoSlug(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()
mux.HandleFunc(fmt.Sprintf("/repo/%s/caches", testRepoSlug), func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, http.MethodDelete)
fmt.Fprint(w, `{"caches": [{"branch":"master","match":"test"}]}`)
})
caches, _, err := client.Caches.DeleteByRepoSlug(context.Background(), testRepoSlug)
if err != nil {
t.Errorf("Caches.DeleteByRepoSlug returned error: %v", err)
}
want := []*Cache{{Branch: String("master"), Match: String("test")}}
if !reflect.DeepEqual(caches, want) {
t.Errorf("Caches.DeleteByRepoSlug returned %+v, want %+v", caches, want)
}
}