~ubuntu-branches/ubuntu/trusty/juju-core/trusty-proposed

« back to all changes in this revision

Viewing changes to src/launchpad.net/juju-core/store/config_test.go

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2014-01-29 11:40:20 UTC
  • mfrom: (23.1.1 trusty-proposed)
  • Revision ID: package-import@ubuntu.com-20140129114020-ejieitm8smtt5vln
Tags: 1.17.1-0ubuntu2
d/tests/local-provider: Don't fail tests if ~/.juju is present as its
created by the juju version command. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright 2012, 2013 Canonical Ltd.
 
2
// Licensed under the AGPLv3, see LICENCE file for details.
 
3
 
 
4
package store_test
 
5
 
 
6
import (
 
7
        "fmt"
 
8
        "os"
 
9
        "path"
 
10
 
 
11
        gc "launchpad.net/gocheck"
 
12
 
 
13
        "launchpad.net/juju-core/store"
 
14
        "launchpad.net/juju-core/testing/testbase"
 
15
)
 
16
 
 
17
type ConfigSuite struct {
 
18
        testbase.LoggingSuite
 
19
}
 
20
 
 
21
var _ = gc.Suite(&ConfigSuite{})
 
22
 
 
23
const testConfig = `
 
24
mongo-url: localhost:23456
 
25
foo: 1
 
26
bar: false
 
27
`
 
28
 
 
29
func (s *ConfigSuite) SetUpSuite(c *gc.C) {
 
30
        s.LoggingSuite.SetUpSuite(c)
 
31
}
 
32
 
 
33
func (s *ConfigSuite) TearDownSuite(c *gc.C) {
 
34
        s.LoggingSuite.TearDownSuite(c)
 
35
}
 
36
 
 
37
func (s *ConfigSuite) TestReadConfig(c *gc.C) {
 
38
        confDir := c.MkDir()
 
39
        f, err := os.Create(path.Join(confDir, "charmd.conf"))
 
40
        c.Assert(err, gc.IsNil)
 
41
        cfgPath := f.Name()
 
42
        {
 
43
                defer f.Close()
 
44
                fmt.Fprint(f, testConfig)
 
45
        }
 
46
 
 
47
        dstr, err := store.ReadConfig(cfgPath)
 
48
        c.Assert(err, gc.IsNil)
 
49
        c.Assert(dstr.MongoURL, gc.Equals, "localhost:23456")
 
50
}