-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdbconfparser_test.go
More file actions
38 lines (32 loc) · 911 Bytes
/
dbconfparser_test.go
File metadata and controls
38 lines (32 loc) · 911 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
33
34
35
36
37
38
package dbconfparser
import (
"testing"
)
func TestParse (t *testing.T) {
driver, open, err := Parse("test/dbconf.yml", "test")
expected1 := "dbms2"
if driver != expected1 {
t.Errorf("got: %v\nwant: %v", driver, expected1)
}
expected2 := "testuser:password@tcp(127.0.0.1:13332)/database_test?parseTime=true"
if open != expected2 {
t.Errorf("got: %v\nwant: %v", open, expected2)
}
if err != nil {
t.Errorf("Error is occured: %v", err)
}
}
func TestReadFile (t *testing.T) {
_, _, err := Parse("hogehoge", "hoge")
expected := "open hogehoge: no such file or directory"
if err.Error() != expected {
t.Errorf("got: %v\nwant: %v", err, expected)
}
}
func TestYamlUnmarshal (t *testing.T) {
_, _, err := Parse("test/dbconferror.yml", "hoge")
expected := "yaml: line 1: did not find expected node content"
if err.Error() != expected {
t.Errorf("got: %v\nwant: %v", err, expected)
}
}