Jamie Hannaford | fac40db | 2015-02-09 17:27:08 +0100 | [diff] [blame] | 1 | package instances |
| 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | |
Jamie Hannaford | 3dbfb2d | 2015-02-10 11:06:47 +0100 | [diff] [blame^] | 6 | "github.com/rackspace/gophercloud" |
Jamie Hannaford | fac40db | 2015-02-09 17:27:08 +0100 | [diff] [blame] | 7 | th "github.com/rackspace/gophercloud/testhelper" |
| 8 | fake "github.com/rackspace/gophercloud/testhelper/client" |
| 9 | ) |
| 10 | |
| 11 | func TestCreate(t *testing.T) { |
| 12 | th.SetupHTTP() |
| 13 | defer th.TeardownHTTP() |
| 14 | |
| 15 | HandleCreateInstanceSuccessfully(t) |
| 16 | |
| 17 | opts := CreateOpts{ |
| 18 | Name: "json_rack_instance", |
| 19 | FlavorRef: "1", |
| 20 | Databases: DatabasesOpts{ |
| 21 | DatabaseOpts{CharSet: "utf8", Collate: "utf8_general_ci", Name: "sampledb"}, |
| 22 | DatabaseOpts{Name: "nextround"}, |
| 23 | }, |
| 24 | Users: UsersOpts{ |
| 25 | UserOpts{ |
| 26 | Name: "demouser", |
| 27 | Password: "demopassword", |
| 28 | Databases: DatabasesOpts{ |
| 29 | DatabaseOpts{Name: "sampledb"}, |
| 30 | }, |
| 31 | }, |
| 32 | }, |
| 33 | Size: 2, |
| 34 | RestorePoint: "1234567890", |
| 35 | } |
| 36 | |
Jamie Hannaford | 3dbfb2d | 2015-02-10 11:06:47 +0100 | [diff] [blame^] | 37 | instance, err := Create(fake.ServiceClient(), opts).Extract() |
| 38 | |
| 39 | expected := &Instance{ |
| 40 | Created: "2014-02-13T21:47:13", |
| 41 | Updated: "2014-02-13T21:47:13", |
| 42 | Datastore: Datastore{Type: "mysql", Version: "5.6"}, |
| 43 | Flavor: Flavor{ |
| 44 | ID: "1", |
| 45 | Links: []gophercloud.Link{ |
| 46 | gophercloud.Link{Href: "https://ord.databases.api.rackspacecloud.com/v1.0/1234/flavors/1", Rel: "self"}, |
| 47 | gophercloud.Link{Href: "https://ord.databases.api.rackspacecloud.com/v1.0/1234/flavors/1", Rel: "bookmark"}, |
| 48 | }, |
| 49 | }, |
| 50 | Hostname: "e09ad9a3f73309469cf1f43d11e79549caf9acf2.rackspaceclouddb.com", |
| 51 | ID: "d4603f69-ec7e-4e9b-803f-600b9205576f", |
| 52 | Links: []gophercloud.Link{ |
| 53 | gophercloud.Link{Href: "https://ord.databases.api.rackspacecloud.com/v1.0/1234/flavors/1", Rel: "self"}, |
| 54 | }, |
| 55 | Name: "json_rack_instance", |
| 56 | Status: "BUILD", |
| 57 | Volume: Volume{Size: 2}, |
| 58 | } |
| 59 | |
| 60 | th.AssertNoErr(t, err) |
| 61 | th.AssertDeepEquals(t, expected, instance) |
Jamie Hannaford | fac40db | 2015-02-09 17:27:08 +0100 | [diff] [blame] | 62 | } |