~jameinel/juju-core/api-login-describe-facades

« back to all changes in this revision

Viewing changes to environs/ec2/config_test.go

  • Committer: Roger Peppe
  • Date: 2011-12-15 18:54:31 UTC
  • mfrom: (19.5.4 go-juju-ec2-operations)
  • mto: This revision was merged to the branch mainline in revision 30.
  • Revision ID: roger.peppe@canonical.com-20111215185431-tjuxi6bmg1mswcwg
renameĀ environ->environs

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
import (
4
4
        "launchpad.net/goamz/aws"
5
5
        . "launchpad.net/gocheck"
6
 
        "launchpad.net/juju/go/juju"
 
6
        "launchpad.net/juju/go/environs"
7
7
        "os"
8
8
        "strings"
9
9
)
10
10
 
11
 
var testRegion = aws.Region{
 
11
var configTestRegion = aws.Region{
12
12
        EC2Endpoint: "testregion.nowhere:1234",
13
13
}
14
14
 
24
24
        {"", &providerConfig{region: aws.USEast, auth: testAuth}, ""},
25
25
        {"region: eu-west-1\n", &providerConfig{region: aws.EUWest, auth: testAuth}, ""},
26
26
        {"region: unknown\n", nil, ".*invalid region name.*"},
27
 
        {"region: test\n", &providerConfig{region: testRegion, auth: testAuth}, ""},
 
27
        {"region: configtest\n", &providerConfig{region: configTestRegion, auth: testAuth}, ""},
28
28
        {"region: 666\n", nil, ".*expected string, got 666"},
29
29
        {"access-key: 666\n", nil, ".*expected string, got 666"},
30
30
        {"secret-key: 666\n", nil, ".*expected string, got 666"},
54
54
}
55
55
 
56
56
func makeEnv(s string) []byte {
57
 
        return []byte("environments:\n  test:\n    type: ec2\n" + indent(s, "    "))
 
57
        return []byte("environments:\n  testenv:\n    type: ec2\n" + indent(s, "    "))
58
58
}
59
59
 
60
60
func (suite) TestConfig(c *C) {
61
 
        Regions["test"] = testRegion
 
61
        Regions["configtest"] = configTestRegion
 
62
        defer delete(Regions, "configtest")
62
63
 
63
64
        defer os.Setenv("AWS_ACCESS_KEY_ID", os.Getenv("AWS_ACCESS_KEY_ID"))
64
65
        defer os.Setenv("AWS_SECRET_ACCESS_KEY", os.Getenv("AWS_SECRET_ACCESS_KEY"))
80
81
}
81
82
 
82
83
func (t configTest) run(c *C) {
83
 
        envs, err := juju.ReadEnvironsBytes(makeEnv(t.env))
 
84
        envs, err := environs.ReadEnvironsBytes(makeEnv(t.env))
84
85
        if err != nil {
85
86
                if t.err != "" {
86
87
                        c.Check(err, ErrorMatches, t.err, Bug("environ %q", t.env))
89
90
                }
90
91
                return
91
92
        }
92
 
        e, err := envs.Open("test")
 
93
        e, err := envs.Open("testenv")
93
94
        c.Assert(err, IsNil)
94
95
        c.Assert(e, NotNil)
95
96
        c.Assert(e, FitsTypeOf, (*environ)(nil), Bug("environ %q", t.env))