-
Notifications
You must be signed in to change notification settings - Fork 2
/
trapmetrics_test.go
58 lines (52 loc) · 1.08 KB
/
trapmetrics_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
// Copyright (c) 2021 Circonus, Inc. <[email protected]>
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//
package trapmetrics
import (
"bytes"
"context"
"fmt"
"testing"
"github.com/circonus-labs/go-apiclient"
"github.com/circonus-labs/go-trapcheck"
)
type FakeTrap struct {
}
func (ft FakeTrap) SendMetrics(_ context.Context, metrics bytes.Buffer) (*trapcheck.TrapResult, error) {
fmt.Println(metrics)
return nil, nil
}
func (ft FakeTrap) UpdateCheckTags(_ context.Context, _ []string) (*apiclient.CheckBundle, error) {
return nil, nil
}
func TestNew(t *testing.T) {
tests := []struct {
cfg *Config
name string
wantErr bool
}{
{
name: "invalid",
cfg: nil,
wantErr: true,
},
{
name: "valid",
cfg: &Config{
Trap: FakeTrap{},
},
wantErr: false,
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
_, err := New(tt.cfg)
if (err != nil) != tt.wantErr {
t.Errorf("New() error = %v, wantErr %v", err, tt.wantErr)
return
}
})
}
}