~fwereade/pyjuju/go-cmd-jujup

« back to all changes in this revision

Viewing changes to environs/jujutest/livetests.go

  • Committer: Roger Peppe
  • Date: 2012-02-17 09:15:22 UTC
  • mfrom: (60.2.6 go-ec2-refactor-tests)
  • Revision ID: roger.peppe@canonical.com-20120217091522-otxmwnsjpqsbt900
environs/ec2: reorganised tests

Also add a unique identifier for the testing
environment name, so that amazon tests don't clash.

R=fwereade, niemeyer
CC=
https://codereview.appspot.com/5676050

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
// that it does not assume a pristine environment.
12
12
func (t *LiveTests) TestStartStop(c *C) {
13
13
        names := make(map[string]environs.Instance)
14
 
        insts, err := t.env.Instances()
 
14
        insts, err := t.Env.Instances()
15
15
        c.Assert(err, IsNil)
16
16
 
17
17
        // check there are no duplicate instance ids
21
21
                names[id] = inst
22
22
        }
23
23
 
24
 
        inst, err := t.env.StartInstance(0)
 
24
        inst, err := t.Env.StartInstance(0)
25
25
        c.Assert(err, IsNil)
26
26
        c.Assert(inst, NotNil)
27
27
        id0 := inst.Id()
28
28
 
29
 
        insts, err = t.env.Instances()
 
29
        insts, err = t.Env.Instances()
30
30
        c.Assert(err, IsNil)
31
31
 
32
32
        // check the new instance is found
39
39
        }
40
40
        c.Check(found, Equals, true)
41
41
 
42
 
        err = t.env.StopInstances([]environs.Instance{inst})
 
42
        err = t.Env.StopInstances([]environs.Instance{inst})
43
43
        c.Assert(err, IsNil)
44
44
 
45
 
        insts, err = t.env.Instances()
 
45
        insts, err = t.Env.Instances()
46
46
        c.Assert(err, IsNil)
47
47
        c.Assert(len(insts), Equals, 0, Bug("instances: %v", insts))
48
48
 
54
54
}
55
55
 
56
56
func (t *LiveTests) TestBootstrap(c *C) {
57
 
        err := t.env.Bootstrap()
 
57
        err := t.Env.Bootstrap()
58
58
        c.Assert(err, IsNil)
59
59
 
60
 
        err = t.env.Bootstrap()
 
60
        err = t.Env.Bootstrap()
61
61
        c.Assert(err, ErrorMatches, "environment is already bootstrapped")
62
62
 
63
 
        err = t.env.Destroy()
 
63
        err = t.Env.Destroy()
64
64
        c.Assert(err, IsNil)
65
65
 
66
66
        // check that we can bootstrap after destroy
67
 
        err = t.env.Bootstrap()
 
67
        err = t.Env.Bootstrap()
68
68
        c.Assert(err, IsNil)
69
69
 
70
 
        err = t.env.Destroy()
 
70
        err = t.Env.Destroy()
71
71
        c.Assert(err, IsNil)
72
72
}
73
73
 
77
77
 
78
78
func (t *LiveTests) TestFile(c *C) {
79
79
        name := fmt.Sprint("testfile", time.Now().UnixNano())
80
 
        checkFileDoesNotExist(c, t.env, name)
81
 
        checkPutFile(c, t.env, name, contents)
82
 
        checkFileHasContents(c, t.env, name, contents)
83
 
        checkPutFile(c, t.env, name, contents2) // check that we can overwrite the file
84
 
        checkFileHasContents(c, t.env, name, contents2)
85
 
        err := t.env.RemoveFile(name)
86
 
        c.Check(err, IsNil)
87
 
        checkFileDoesNotExist(c, t.env, name)
 
80
        checkFileDoesNotExist(c, t.Env, name)
 
81
        checkPutFile(c, t.Env, name, contents)
 
82
        checkFileHasContents(c, t.Env, name, contents)
 
83
        checkPutFile(c, t.Env, name, contents2) // check that we can overwrite the file
 
84
        checkFileHasContents(c, t.Env, name, contents2)
 
85
        err := t.Env.RemoveFile(name)
 
86
        c.Check(err, IsNil)
 
87
        checkFileDoesNotExist(c, t.Env, name)
 
88
        // removing a file that does not exist should not be an error.
 
89
        err = t.Env.RemoveFile(name)
 
90
        c.Check(err, IsNil)
88
91
}