1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
|
package testing
import (
"testing"
"github.com/gophercloud/gophercloud/openstack/baremetal/v1/drivers"
"github.com/gophercloud/gophercloud/pagination"
th "github.com/gophercloud/gophercloud/testhelper"
"github.com/gophercloud/gophercloud/testhelper/client"
)
func TestListDrivers(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
HandleListDriversSuccessfully(t)
pages := 0
err := drivers.ListDrivers(client.ServiceClient(), drivers.ListDriversOpts{}).EachPage(func(page pagination.Page) (bool, error) {
pages++
actual, err := drivers.ExtractDrivers(page)
if err != nil {
return false, err
}
if len(actual) != 3 {
t.Fatalf("Expected 3 drivers, got %d", len(actual))
}
th.CheckDeepEquals(t, DriverAgentIpmitool, actual[0])
th.CheckDeepEquals(t, DriverFake, actual[1])
th.AssertEquals(t, "ipmi", actual[2].Name)
return true, nil
})
th.AssertNoErr(t, err)
if pages != 1 {
t.Errorf("Expected 1 page, saw %d", pages)
}
}
func TestGetDriverDetails(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
HandleGetDriverDetailsSuccessfully(t)
c := client.ServiceClient()
actual, err := drivers.GetDriverDetails(c, "ipmi").Extract()
if err != nil {
t.Fatalf("Unexpected Get error: %v", err)
}
th.CheckDeepEquals(t, DriverIpmi, *actual)
}
func TestGetDriverProperties(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
HandleGetDriverPropertiesSuccessfully(t)
c := client.ServiceClient()
actual, err := drivers.GetDriverProperties(c, "agent_ipmitool").Extract()
if err != nil {
t.Fatalf("Unexpected Get error: %v", err)
}
th.CheckDeepEquals(t, DriverIpmiToolProperties, *actual)
}
func TestGetDriverDiskProperties(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
HandleGetDriverDiskPropertiesSuccessfully(t)
c := client.ServiceClient()
actual, err := drivers.GetDriverDiskProperties(c, "agent_ipmitool").Extract()
if err != nil {
t.Fatalf("Unexpected Get error: %v", err)
}
th.CheckDeepEquals(t, DriverIpmiToolDisk, *actual)
}
|