OLD | NEW |
1 // Copyright 2012, 2013 Canonical Ltd. | 1 // Copyright 2012, 2013 Canonical Ltd. |
2 // Licensed under the AGPLv3, see LICENCE file for details. | 2 // Licensed under the AGPLv3, see LICENCE file for details. |
3 | 3 |
4 package tools_test | 4 package tools_test |
5 | 5 |
6 import ( | 6 import ( |
7 "bytes" | 7 "bytes" |
8 "fmt" | 8 "fmt" |
9 "io/ioutil" | 9 "io/ioutil" |
10 "os" | 10 "os" |
| 11 "path" |
11 "path/filepath" | 12 "path/filepath" |
12 "time" | 13 "time" |
13 | 14 |
14 gc "launchpad.net/gocheck" | 15 gc "launchpad.net/gocheck" |
15 "launchpad.net/loggo" | 16 "launchpad.net/loggo" |
16 | 17 |
17 "launchpad.net/juju-core/environs" | 18 "launchpad.net/juju-core/environs" |
18 "launchpad.net/juju-core/environs/config" | 19 "launchpad.net/juju-core/environs/config" |
19 "launchpad.net/juju-core/environs/simplestreams" | 20 "launchpad.net/juju-core/environs/simplestreams" |
20 "launchpad.net/juju-core/environs/storage" | 21 "launchpad.net/juju-core/environs/storage" |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 } | 145 } |
145 index, products, err := envtools.MarshalToolsMetadataJSON(metadata, time
.Now()) | 146 index, products, err := envtools.MarshalToolsMetadataJSON(metadata, time
.Now()) |
146 c.Assert(err, gc.IsNil) | 147 c.Assert(err, gc.IsNil) |
147 objects := []metadataFile{ | 148 objects := []metadataFile{ |
148 {simplestreams.DefaultIndexPath + simplestreams.UnsignedSuffix,
index}, | 149 {simplestreams.DefaultIndexPath + simplestreams.UnsignedSuffix,
index}, |
149 {envtools.ProductMetadataPath, products}, | 150 {envtools.ProductMetadataPath, products}, |
150 } | 151 } |
151 return objects | 152 return objects |
152 } | 153 } |
153 | 154 |
154 func (s *SimpleStreamsToolsSuite) uploadToStorage(c *gc.C, storage storage.Stora
ge, verses ...version.Binary) map[version.Binary]string { | 155 func (s *SimpleStreamsToolsSuite) uploadToStorage(c *gc.C, stor storage.Storage,
verses ...version.Binary) map[version.Binary]string { |
155 uploaded := map[version.Binary]string{} | 156 uploaded := map[version.Binary]string{} |
156 if len(verses) == 0 { | 157 if len(verses) == 0 { |
157 return uploaded | 158 return uploaded |
158 } | 159 } |
159 var err error | 160 var err error |
160 for _, vers := range verses { | 161 for _, vers := range verses { |
161 » » uploaded[vers], err = storage.URL(fmt.Sprintf("tools/releases/to
ols-%s.tar.gz", vers.String())) | 162 » » uploaded[vers], err = stor.URL(fmt.Sprintf("tools/releases/tools
-%s.tar.gz", vers.String())) |
162 c.Assert(err, gc.IsNil) | 163 c.Assert(err, gc.IsNil) |
163 } | 164 } |
164 objects := s.generateMetadata(c, verses...) | 165 objects := s.generateMetadata(c, verses...) |
165 for _, object := range objects { | 166 for _, object := range objects { |
166 » » path := filepath.Join("tools", object.path) | 167 » » toolspath := path.Join("tools", object.path) |
167 » » err = storage.Put(path, bytes.NewReader(object.data), int64(len(
object.data))) | 168 » » err = stor.Put(toolspath, bytes.NewReader(object.data), int64(le
n(object.data))) |
168 c.Assert(err, gc.IsNil) | 169 c.Assert(err, gc.IsNil) |
169 } | 170 } |
170 return uploaded | 171 return uploaded |
171 } | 172 } |
172 | 173 |
173 func (s *SimpleStreamsToolsSuite) uploadVersions(c *gc.C, dir string, verses ...
version.Binary) map[version.Binary]string { | 174 func (s *SimpleStreamsToolsSuite) uploadVersions(c *gc.C, dir string, verses ...
version.Binary) map[version.Binary]string { |
174 uploaded := map[version.Binary]string{} | 175 uploaded := map[version.Binary]string{} |
175 if len(verses) == 0 { | 176 if len(verses) == 0 { |
176 return uploaded | 177 return uploaded |
177 } | 178 } |
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
575 c.Assert(err, gc.NotNil) | 576 c.Assert(err, gc.NotNil) |
576 c.Check(err, gc.ErrorMatches, "tools mismatch: expected series warty, go
t hoary") | 577 c.Check(err, gc.ErrorMatches, "tools mismatch: expected series warty, go
t hoary") |
577 } | 578 } |
578 | 579 |
579 func (s *ToolsListSuite) TestCheckToolsSeriesRejectsToolsForMixedSeries(c *gc.C)
{ | 580 func (s *ToolsListSuite) TestCheckToolsSeriesRejectsToolsForMixedSeries(c *gc.C)
{ |
580 list := fakeToolsList("precise", "raring") | 581 list := fakeToolsList("precise", "raring") |
581 err := envtools.CheckToolsSeries(list, "precise") | 582 err := envtools.CheckToolsSeries(list, "precise") |
582 c.Assert(err, gc.NotNil) | 583 c.Assert(err, gc.NotNil) |
583 c.Check(err, gc.ErrorMatches, "expected single series, got .*") | 584 c.Check(err, gc.ErrorMatches, "expected single series, got .*") |
584 } | 585 } |
OLD | NEW |