4
5
. "launchpad.net/gocheck"
5
6
"launchpad.net/ensemble/go/formula"
14
description: A descriptive title used for the service.
17
description: No default outlook.
21
description: The name of the initial account (given admin permissions).
24
description: A number indicating skill.
9
28
func repoConfig(name string) (path string) {
10
29
return filepath.Join("testrepo", name, "config.yaml")
32
func assertDummyConfig(c *C, config *formula.Config) {
33
c.Assert(config.Options["title"], Equals,
36
Description: "A descriptive title used for the service.",
13
42
func (s *S) TestReadConfig(c *C) {
14
43
config, err := formula.ReadConfig(repoConfig("dummy"))
15
44
c.Assert(err, IsNil)
16
c.Assert(config.Options["title"], Equals,
45
assertDummyConfig(c, config)
48
func (s *S) TestParseConfig(c *C) {
49
data, err := ioutil.ReadFile(repoConfig("dummy"))
52
config, err := formula.ParseConfig(data)
54
assertDummyConfig(c, config)
57
func (s *S) TestConfigErrorWithPath(c *C) {
58
path := filepath.Join(c.MkDir(), "mymeta.yaml")
60
_, err := formula.ReadConfig(path)
61
c.Assert(err, Matches, `.*/.*/mymeta\.yaml.*no such file.*`)
63
data := `options: {t: {type: foo}}`
64
err = ioutil.WriteFile(path, []byte(data), 0644)
67
_, err = formula.ReadConfig(path)
68
c.Assert(err, Matches, `/.*/mymeta\.yaml: options.t.type: unsupported value`)
71
func (s *S) TestParseSample(c *C) {
72
config, err := formula.ParseConfig([]byte(sampleConfig))
76
c.Assert(opt["title"], Equals,
18
78
Default: "My Title",
19
79
Description: "A descriptive title used for the service.",
83
c.Assert(opt["outlook"], Equals,
85
Description: "No default outlook.",
89
c.Assert(opt["username"], Equals,
92
Description: "The name of the initial account (given admin permissions).",
96
c.Assert(opt["skill-level"], Equals,
98
Description: "A number indicating skill.",