~rogpeppe/juju-core/438-local-instance-Addresses

« back to all changes in this revision

Viewing changes to formula/formula_test.go

  • Committer: Gustavo Niemeyer
  • Date: 2011-09-05 22:26:13 UTC
  • mto: This revision was merged to the branch mainline in revision 7.
  • Revision ID: gustavo@niemeyer.net-20110905222613-7im2u2s2dbxy1a3z
Implemented initial config parsing. No variable validation using the
parsed schema yet.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
package formula_test
2
2
 
3
3
import (
 
4
        "io/ioutil"
4
5
        "testing"
5
6
        . "launchpad.net/gocheck"
6
7
        "launchpad.net/ensemble/go/formula"
 
8
        "launchpad.net/goyaml"
7
9
)
8
10
 
9
11
 
34
36
        _, _, _, err = formula.ParseId("local:foo-x")
35
37
        c.Assert(err, Matches, `Missing formula revision: "local:foo-x"`)
36
38
}
 
39
 
 
40
func ReadYaml(path string) map[interface{}]interface{} {
 
41
        data, err := ioutil.ReadFile(path)
 
42
        if err != nil {
 
43
                panic(err)
 
44
        }
 
45
        m := make(map[interface{}]interface{})
 
46
        err = goyaml.Unmarshal(data, m)
 
47
        if err != nil {
 
48
                panic(err)
 
49
        }
 
50
        return m
 
51
}
 
52
 
 
53
func DumpYaml(v interface{}) []byte {
 
54
        data, err := goyaml.Marshal(v)
 
55
        if err != nil {
 
56
                panic(err)
 
57
        }
 
58
        return data
 
59
}