-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathconfiguration_test.go
43 lines (35 loc) · 1.1 KB
/
configuration_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
package honeybadger
import "testing"
type TestLogger struct{}
func (l *TestLogger) Printf(format string, v ...interface{}) {}
type TestBackend struct{}
func (l *TestBackend) Notify(f Feature, p Payload) (err error) {
return
}
func TestUpdateConfig(t *testing.T) {
config := &Configuration{}
logger := &TestLogger{}
backend := &TestBackend{}
config.update(&Configuration{
Logger: logger,
Backend: backend,
Root: "/tmp/foo",
})
if config.Logger != logger {
t.Errorf("Expected config to update logger expected=%#v actual=%#v", logger, config.Logger)
}
if config.Backend != backend {
t.Errorf("Expected config to update backend expected=%#v actual=%#v", backend, config.Backend)
}
if config.Root != "/tmp/foo" {
t.Errorf("Expected config to update root expected=%#v actual=%#v", "/tmp/foo", config.Root)
}
}
func TestReplaceConfigPointer(t *testing.T) {
config := Configuration{Root: "/tmp/foo"}
root := &config.Root
config = Configuration{Root: "/tmp/bar"}
if *root != "/tmp/bar" {
t.Errorf("Expected updated config to update pointer expected=%#v actual=%#v", "/tmp/bar", *root)
}
}