~themue/pyjuju/go-state-auth

« back to all changes in this revision

Viewing changes to environs/ec2/image_test.go

  • Committer: Roger Peppe
  • Date: 2012-03-21 16:05:41 UTC
  • mfrom: (90.2.11 go-ec2-local-images)
  • Revision ID: roger.peppe@canonical.com-20120321160541-m0eb1nz27jnz8ot3
environs/ec2: use local images data for local tests

R=niemeyer
CC=
https://codereview.appspot.com/5866049

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
        "testing"
12
12
)
13
13
 
 
14
type imageSuite struct{}
 
15
 
 
16
var _ = Suite(imageSuite{})
 
17
 
 
18
func (imageSuite) SetUpSuite(c *C) {
 
19
        ec2.UseTestImageData(true)
 
20
}
 
21
 
 
22
func (imageSuite) TearDownSuite(c *C) {
 
23
        ec2.UseTestImageData(false)
 
24
}
 
25
 
14
26
// N.B. the image IDs in this test will need updating
15
27
// if the image directory is regenerated.
16
28
var imageTests = []struct {
61
73
        }, "", "error getting instance types:.*"},
62
74
}
63
75
 
64
 
func (suite) TestFindImageSpec(c *C) {
65
 
        // set up http so that all requests will be satisfied from the images directory.
66
 
        defer setTransport(setTransport(http.NewFileTransport(http.Dir("images"))))
 
76
func (imageSuite) TestFindImageSpec(c *C) {
67
77
 
68
78
        for i, t := range imageTests {
69
79
                id, err := ec2.FindImageSpec(&t.constraint)
82
92
        }
83
93
}
84
94
 
85
 
func setTransport(t http.RoundTripper) (old http.RoundTripper) {
86
 
        old = http.DefaultTransport
87
 
        http.DefaultTransport = t
88
 
        return
89
 
}
90
 
 
91
95
// regenerate all data inside the images directory.
92
96
// N.B. this second-guesses the logic inside images.go
93
97
func regenerateImages(t *testing.T) {