Joe Topjian | 59c5783 | 2016-07-25 18:43:05 +0000 | [diff] [blame] | 1 | // +build acceptance compute extensions |
Ash Wilson | a5b1a14 | 2014-10-22 10:16:03 -0400 | [diff] [blame] | 2 | |
| 3 | package v2 |
| 4 | |
| 5 | import ( |
| 6 | "testing" |
| 7 | |
Joe Topjian | 1c15e3f | 2016-08-08 10:48:38 -0600 | [diff] [blame] | 8 | "github.com/gophercloud/gophercloud/acceptance/clients" |
Joe Topjian | 66a046c | 2017-01-19 22:07:26 -0700 | [diff] [blame] | 9 | "github.com/gophercloud/gophercloud/acceptance/tools" |
Joe Topjian | 59c5783 | 2016-07-25 18:43:05 +0000 | [diff] [blame] | 10 | "github.com/gophercloud/gophercloud/openstack/common/extensions" |
Ash Wilson | a5b1a14 | 2014-10-22 10:16:03 -0400 | [diff] [blame] | 11 | ) |
| 12 | |
Joe Topjian | 59c5783 | 2016-07-25 18:43:05 +0000 | [diff] [blame] | 13 | func TestExtensionsList(t *testing.T) { |
Joe Topjian | 1c15e3f | 2016-08-08 10:48:38 -0600 | [diff] [blame] | 14 | client, err := clients.NewComputeV2Client() |
Joe Topjian | 59c5783 | 2016-07-25 18:43:05 +0000 | [diff] [blame] | 15 | if err != nil { |
| 16 | t.Fatalf("Unable to create a compute client: %v", err) |
| 17 | } |
Ash Wilson | a5b1a14 | 2014-10-22 10:16:03 -0400 | [diff] [blame] | 18 | |
Joe Topjian | 59c5783 | 2016-07-25 18:43:05 +0000 | [diff] [blame] | 19 | allPages, err := extensions.List(client).AllPages() |
| 20 | if err != nil { |
| 21 | t.Fatalf("Unable to list extensions: %v", err) |
| 22 | } |
Ash Wilson | a5b1a14 | 2014-10-22 10:16:03 -0400 | [diff] [blame] | 23 | |
Joe Topjian | 59c5783 | 2016-07-25 18:43:05 +0000 | [diff] [blame] | 24 | allExtensions, err := extensions.ExtractExtensions(allPages) |
| 25 | if err != nil { |
| 26 | t.Fatalf("Unable to extract extensions: %v", err) |
| 27 | } |
Ash Wilson | a5b1a14 | 2014-10-22 10:16:03 -0400 | [diff] [blame] | 28 | |
Joe Topjian | 59c5783 | 2016-07-25 18:43:05 +0000 | [diff] [blame] | 29 | for _, extension := range allExtensions { |
Joe Topjian | 66a046c | 2017-01-19 22:07:26 -0700 | [diff] [blame] | 30 | tools.PrintResource(t, extension) |
Joe Topjian | 59c5783 | 2016-07-25 18:43:05 +0000 | [diff] [blame] | 31 | } |
Ash Wilson | a5b1a14 | 2014-10-22 10:16:03 -0400 | [diff] [blame] | 32 | } |
| 33 | |
Joe Topjian | 59c5783 | 2016-07-25 18:43:05 +0000 | [diff] [blame] | 34 | func TestExtensionGet(t *testing.T) { |
Joe Topjian | 1c15e3f | 2016-08-08 10:48:38 -0600 | [diff] [blame] | 35 | client, err := clients.NewComputeV2Client() |
Joe Topjian | 59c5783 | 2016-07-25 18:43:05 +0000 | [diff] [blame] | 36 | if err != nil { |
| 37 | t.Fatalf("Unable to create a compute client: %v", err) |
| 38 | } |
Ash Wilson | a5b1a14 | 2014-10-22 10:16:03 -0400 | [diff] [blame] | 39 | |
Joe Topjian | 59c5783 | 2016-07-25 18:43:05 +0000 | [diff] [blame] | 40 | extension, err := extensions.Get(client, "os-admin-actions").Extract() |
| 41 | if err != nil { |
| 42 | t.Fatalf("Unable to get extension os-admin-actions: %v", err) |
| 43 | } |
Ash Wilson | a5b1a14 | 2014-10-22 10:16:03 -0400 | [diff] [blame] | 44 | |
Joe Topjian | 66a046c | 2017-01-19 22:07:26 -0700 | [diff] [blame] | 45 | tools.PrintResource(t, extension) |
Ash Wilson | a5b1a14 | 2014-10-22 10:16:03 -0400 | [diff] [blame] | 46 | } |