forked from zalando/postgres-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config_test.go
31 lines (28 loc) · 1.02 KB
/
config_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
package config
import (
"fmt"
"reflect"
"testing"
)
var getMapPairsFromStringTest = []struct {
in string
expected []string
err error
}{
{"log_statement:all, work_mem:'4GB'", []string{"log_statement:all", "work_mem:'4GB'"}, nil},
{`log_statement:none, search_path:'"$user", public'`, []string{"log_statement:none", `search_path:'"$user", public'`}, nil},
{`search_path:'"$user"`, nil, fmt.Errorf("unmatched quote starting at position 13")},
{"", []string{""}, nil},
{",,log_statement:all ,", []string{"", "", "log_statement:all", ""}, nil},
}
func TestGetMapPairsFromString(t *testing.T) {
for _, tt := range getMapPairsFromStringTest {
got, err := getMapPairsFromString(tt.in)
if err != tt.err && ((err == nil || tt.err == nil) || (err.Error() != tt.err.Error())) {
t.Errorf("TestGetMapPairsFromString with %s: expected error: %#v, got %#v", tt.in, tt.err, err)
}
if !reflect.DeepEqual(got, tt.expected) {
t.Errorf("TestGetMapPairsFromString with %s: expected %#v, got %#v", tt.in, tt.expected, got)
}
}
}