-
Notifications
You must be signed in to change notification settings - Fork 19
/
interpolation_test.go
50 lines (40 loc) · 1.58 KB
/
interpolation_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
package configparser_test
import (
"github.com/bigkevmcd/go-configparser"
. "gopkg.in/check.v1"
)
// GetInterpolated(section, option) should return an appropriate error if the section does not exist
func (s *ConfigParserSuite) TestGetInterpolatedWithMissingSection(c *C) {
_, err := s.p.GetInterpolated("unknown", "missing")
c.Assert(err, ErrorMatches, "no section: \"unknown\"")
}
// GetInterpolated(section, option) should interpolate the result
func (s *ConfigParserSuite) TestGetInterpolated(c *C) {
result, err := s.p.GetInterpolated("follower", "builder_command")
c.Assert(err, IsNil)
c.Assert(result, Equals, "/srv/bin/build")
}
// GetInterpolatedWithVars(section, option, vars) should interpolate the result
// with the additional variables provided
func (s *ConfigParserSuite) TestGetInterpolatedWithVars(c *C) {
d := make(configparser.Dict)
d["bin_dir"] = "/a/non/existent/path"
result, err := s.p.GetInterpolatedWithVars("follower", "builder_command", d)
c.Assert(err, IsNil)
c.Assert(result, Equals, "/a/non/existent/path/build")
}
// ItemsInterpolated(section) should return a copy of the section Dict
// but with the values interpolated
func (s *ConfigParserSuite) TestItemsWithDefaultsInterpolated(c *C) {
result, err := s.p.ItemsWithDefaultsInterpolated("follower")
c.Assert(err, IsNil)
c.Assert(result, DeepEquals, configparser.Dict{
"builder_command": "/srv/bin/build",
"bin_dir": "/srv/bin",
"FrobTimeout": "5",
"TableName": "MyCaseSensitiveTableName",
"max_build_time": "200",
"log_dir": "/srv/logs",
"base_dir": "/srv",
})
}