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