blob: 5b2cf4a42de164967c89d9b59db1de3c5bbd0bfe [file] [log] [blame]
Joe Topjian59c57832016-07-25 18:43:05 +00001// +build acceptance compute extensions
Ash Wilsona5b1a142014-10-22 10:16:03 -04002
3package v2
4
5import (
6 "testing"
7
Joe Topjian1c15e3f2016-08-08 10:48:38 -06008 "github.com/gophercloud/gophercloud/acceptance/clients"
Joe Topjian66a046c2017-01-19 22:07:26 -07009 "github.com/gophercloud/gophercloud/acceptance/tools"
Joe Topjian59c57832016-07-25 18:43:05 +000010 "github.com/gophercloud/gophercloud/openstack/common/extensions"
Ash Wilsona5b1a142014-10-22 10:16:03 -040011)
12
Joe Topjian59c57832016-07-25 18:43:05 +000013func TestExtensionsList(t *testing.T) {
Joe Topjian1c15e3f2016-08-08 10:48:38 -060014 client, err := clients.NewComputeV2Client()
Joe Topjian59c57832016-07-25 18:43:05 +000015 if err != nil {
16 t.Fatalf("Unable to create a compute client: %v", err)
17 }
Ash Wilsona5b1a142014-10-22 10:16:03 -040018
Joe Topjian59c57832016-07-25 18:43:05 +000019 allPages, err := extensions.List(client).AllPages()
20 if err != nil {
21 t.Fatalf("Unable to list extensions: %v", err)
22 }
Ash Wilsona5b1a142014-10-22 10:16:03 -040023
Joe Topjian59c57832016-07-25 18:43:05 +000024 allExtensions, err := extensions.ExtractExtensions(allPages)
25 if err != nil {
26 t.Fatalf("Unable to extract extensions: %v", err)
27 }
Ash Wilsona5b1a142014-10-22 10:16:03 -040028
Joe Topjian59c57832016-07-25 18:43:05 +000029 for _, extension := range allExtensions {
Joe Topjian66a046c2017-01-19 22:07:26 -070030 tools.PrintResource(t, extension)
Joe Topjian59c57832016-07-25 18:43:05 +000031 }
Ash Wilsona5b1a142014-10-22 10:16:03 -040032}
33
Joe Topjian59c57832016-07-25 18:43:05 +000034func TestExtensionGet(t *testing.T) {
Joe Topjian1c15e3f2016-08-08 10:48:38 -060035 client, err := clients.NewComputeV2Client()
Joe Topjian59c57832016-07-25 18:43:05 +000036 if err != nil {
37 t.Fatalf("Unable to create a compute client: %v", err)
38 }
Ash Wilsona5b1a142014-10-22 10:16:03 -040039
Joe Topjian59c57832016-07-25 18:43:05 +000040 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 Wilsona5b1a142014-10-22 10:16:03 -040044
Joe Topjian66a046c2017-01-19 22:07:26 -070045 tools.PrintResource(t, extension)
Ash Wilsona5b1a142014-10-22 10:16:03 -040046}