-
Notifications
You must be signed in to change notification settings - Fork 0
/
source_test.go
42 lines (33 loc) · 954 Bytes
/
source_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
package benthos
import (
"context"
"strings"
"testing"
)
func TestConfigureSource_FailsWhenConfigEmpty(t *testing.T) {
con := Source{}
err := con.Configure(context.Background(), make(map[string]string))
if err != nil {
t.Errorf("expected no error, got %v", err)
}
if strings.HasPrefix(err.Error(), "config is invalid:") {
t.Errorf("expected error to be about missing config, got %v", err)
}
}
func TestConfigureSource_FailsWhenConfigInvalid(t *testing.T) {
con := Source{}
err := con.Configure(context.Background(), map[string]string{"foobar": "foobar"})
if err != nil {
t.Errorf("expected no error, got %v", err)
}
if strings.HasPrefix(err.Error(), "config is missing:") {
t.Errorf("expected error to be about invalid config, got %v", err)
}
}
func TestTeardownSource_NoOpen(t *testing.T) {
con := NewSource()
err := con.Teardown(context.Background())
if err != nil {
t.Errorf("expected no error, got %v", err)
}
}