| 1 |
package cloudapi_test |
| 2 |
|
| 3 |
import ( |
| 4 |
gc "launchpad.net/gocheck" |
| 5 |
|
| 6 |
"github.com/joyent/gosdc/cloudapi" |
| 7 |
) |
| 8 |
|
| 9 |
|
| 10 |
func (s *LocalTests) TestListImages(c *gc.C) { |
| 11 |
imgs, err := s.testClient.ListImages(nil) |
| 12 |
c.Assert(err, gc.IsNil) |
| 13 |
c.Assert(imgs, gc.NotNil) |
| 14 |
for _, img := range imgs { |
| 15 |
c.Check(img.Id, gc.FitsTypeOf, string("")) |
| 16 |
c.Check(img.Name, gc.FitsTypeOf, string("")) |
| 17 |
c.Check(img.OS, gc.FitsTypeOf, string("")) |
| 18 |
c.Check(img.Version, gc.FitsTypeOf, string("")) |
| 19 |
c.Check(img.Type, gc.FitsTypeOf, string("")) |
| 20 |
c.Check(img.Description, gc.FitsTypeOf, string("")) |
| 21 |
c.Check(img.Requirements, gc.FitsTypeOf, map[string]interface{}{"key": "value"}) |
| 22 |
c.Check(img.Homepage, gc.FitsTypeOf, string("")) |
| 23 |
c.Check(img.PublishedAt, gc.FitsTypeOf, string("")) |
| 24 |
c.Check(img.Public, gc.FitsTypeOf, bool(true)) |
| 25 |
c.Check(img.State, gc.FitsTypeOf, string("")) |
| 26 |
c.Check(img.Tags, gc.FitsTypeOf, map[string]string{"key": "value"}) |
| 27 |
c.Check(img.EULA, gc.FitsTypeOf, string("")) |
| 28 |
c.Check(img.ACL, gc.FitsTypeOf, []string{"", ""}) |
| 29 |
} |
| 30 |
} |
| 31 |
|
| 32 |
func (s *LocalTests) TestListImagesWithFilter(c *gc.C) { |
| 33 |
filter := cloudapi.NewFilter() |
| 34 |
filter.Set("os", "smartos") |
| 35 |
imgs, err := s.testClient.ListImages(filter) |
| 36 |
c.Assert(err, gc.IsNil) |
| 37 |
c.Assert(imgs, gc.NotNil) |
| 38 |
for _, img := range imgs { |
| 39 |
c.Check(img.Id, gc.FitsTypeOf, string("")) |
| 40 |
c.Check(img.Name, gc.FitsTypeOf, string("")) |
| 41 |
c.Check(img.OS, gc.Equals, "smartos") |
| 42 |
c.Check(img.Version, gc.FitsTypeOf, string("")) |
| 43 |
c.Check(img.Type, gc.FitsTypeOf, string("")) |
| 44 |
c.Check(img.Description, gc.FitsTypeOf, string("")) |
| 45 |
c.Check(img.Requirements, gc.FitsTypeOf, map[string]interface{}{"key": "value"}) |
| 46 |
c.Check(img.Homepage, gc.FitsTypeOf, string("")) |
| 47 |
c.Check(img.PublishedAt, gc.FitsTypeOf, string("")) |
| 48 |
c.Check(img.Public, gc.FitsTypeOf, bool(true)) |
| 49 |
c.Check(img.State, gc.FitsTypeOf, string("")) |
| 50 |
c.Check(img.Tags, gc.FitsTypeOf, map[string]string{"key": "value"}) |
| 51 |
c.Check(img.EULA, gc.FitsTypeOf, string("")) |
| 52 |
c.Check(img.ACL, gc.FitsTypeOf, []string{"", ""}) |
| 53 |
} |
| 54 |
} |
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
func (s *LocalTests) TestGetImage(c *gc.C) { |
| 59 |
img, err := s.testClient.GetImage(localImageID) |
| 60 |
c.Assert(err, gc.IsNil) |
| 61 |
c.Assert(img, gc.NotNil) |
| 62 |
c.Assert(img, gc.DeepEquals, &cloudapi.Image{ |
| 63 |
Id: "12345678-a1a1-b2b2-c3c3-098765432100", |
| 64 |
Name: "SmartOS Std", |
| 65 |
OS: "smartos", |
| 66 |
Version: "13.3.1", |
| 67 |
Type: "smartmachine", |
| 68 |
Description: "Test SmartOS image (32 bit)", |
| 69 |
Homepage: "http://test.joyent.com/Standard_Instance", |
| 70 |
PublishedAt: "2014-01-08T17:42:31Z", |
| 71 |
Public: true, |
| 72 |
State: "active", |
| 73 |
}) |
| 74 |
} |