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
/
logs_test.go
56 lines (44 loc) · 1.5 KB
/
logs_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
// 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 TestLogsService_FindByJobId(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()
mux.HandleFunc(fmt.Sprintf("/job/%d/log", testJobId), func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, http.MethodGet)
fmt.Fprint(w, `{"id":1,"content":"test"}`)
})
log, _, err := client.Logs.FindByJobId(context.Background(), testJobId)
if err != nil {
t.Errorf("Log.FindByJobId returned error: %v", err)
}
want := &Log{Id: Uint(1), Content: String("test")}
if !reflect.DeepEqual(log, want) {
t.Errorf("Log.FindByJobId returned %+v, want %+v", log, want)
}
}
func TestLogsService_DeleteByJobId(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()
mux.HandleFunc(fmt.Sprintf("/job/%d/log", testJobId), func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, http.MethodDelete)
fmt.Fprint(w, `{"id":1,"content":"Log removed by XXX at 2017-02-13 16:00:00 UTC"}`)
})
log, _, err := client.Logs.DeleteByJobId(context.Background(), testJobId)
if err != nil {
t.Errorf("Log.DeleteByJobId returned error: %v", err)
}
want := &Log{Id: Uint(1), Content: String("Log removed by XXX at 2017-02-13 16:00:00 UTC")}
if !reflect.DeepEqual(log, want) {
t.Errorf("Log.DeleteByJobId returned %+v, want %+v", log, want)
}
}