-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathconfig_test.go
More file actions
32 lines (29 loc) · 974 Bytes
/
config_test.go
File metadata and controls
32 lines (29 loc) · 974 Bytes
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
package python
import (
"strings"
"testing"
)
func TestParseConfigDisallowUnknownFields(t *testing.T) {
_, err := parseConfig([]byte(`{"emit_sync_querier":true,"db_typ":"jsonb"}`))
if err == nil {
t.Fatal("expected unknown field error, got nil")
}
if !strings.Contains(err.Error(), "invalid plugin options") {
t.Fatalf("expected error to reference plugin options, got: %v", err)
}
if !strings.Contains(err.Error(), `unknown field "db_typ"`) {
t.Fatalf("expected unknown field in error, got: %v", err)
}
}
func TestParseConfigValid(t *testing.T) {
conf, err := parseConfig([]byte(`{"emit_sync_querier":true,"overrides":[{"db_type":"jsonb","py_type":"str"}]}`))
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
if !conf.EmitSyncQuerier {
t.Fatal("expected emit_sync_querier to be true")
}
if len(conf.Overrides) != 1 || conf.Overrides[0].DbType != "jsonb" || conf.Overrides[0].PyType != "str" {
t.Fatal("unexpected parsed overrides")
}
}