-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdavinci_test.go
71 lines (62 loc) · 1.05 KB
/
davinci_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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package main
import (
"github.com/davecgh/go-spew/spew"
"testing"
)
func createSesh() *Session {
return &Session{
Config: &Config{
Options: Options{
Paths: []string{
"./testdata/envs0",
"./testdata/envs1",
},
},
},
}
}
func TestSearch(t *testing.T) {
var s *Session = createSesh()
terms := []string{"dev", "prod", "foo", "bar"}
units, _ := s.Search(terms)
spew.Dump(units)
if units[0] != "testdata/envs0/dev/foo.sh" {
t.Fail()
}
if units[1] != "testdata/envs0/prod/foo.sh" {
t.Fail()
}
if units[2] != "testdata/envs1/bar/foo.sh" {
t.Fail()
}
if units[3] != "testdata/envs1/foo/foo.sh" {
t.Fail()
}
}
func TestLoadConfig_path_exists(t *testing.T) {
var data = `
---
options:
paths:
- './testdata'
`
config, err := LoadConfigData(data)
if err != nil {
t.Error(err)
}
if config.Options.Paths[0] != "./testdata" {
t.Fail()
}
}
func TestLoadConfig_path_non_exists(t *testing.T) {
var data = `
---
options:
paths:
- './foobar'
`
_, err := LoadConfigData(data)
if err == nil {
t.Fail()
}
}