github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/blockstorage/v1/apiversions/testing/requests_test.go (about) 1 package testing 2 3 import ( 4 "testing" 5 6 "github.com/huaweicloud/golangsdk/openstack/blockstorage/v1/apiversions" 7 "github.com/huaweicloud/golangsdk/pagination" 8 th "github.com/huaweicloud/golangsdk/testhelper" 9 "github.com/huaweicloud/golangsdk/testhelper/client" 10 ) 11 12 func TestListVersions(t *testing.T) { 13 th.SetupHTTP() 14 defer th.TeardownHTTP() 15 16 MockListResponse(t) 17 18 count := 0 19 20 apiversions.List(client.ServiceClient()).EachPage(func(page pagination.Page) (bool, error) { 21 count++ 22 actual, err := apiversions.ExtractAPIVersions(page) 23 th.AssertNoErr(t, err) 24 25 expected := []apiversions.APIVersion{ 26 { 27 ID: "v1.0", 28 Status: "CURRENT", 29 Updated: "2012-01-04T11:33:21Z", 30 }, 31 { 32 ID: "v2.0", 33 Status: "CURRENT", 34 Updated: "2012-11-21T11:33:21Z", 35 }, 36 } 37 38 th.AssertDeepEquals(t, expected, actual) 39 40 return true, nil 41 }) 42 43 th.AssertEquals(t, 1, count) 44 } 45 46 func TestAPIInfo(t *testing.T) { 47 th.SetupHTTP() 48 defer th.TeardownHTTP() 49 50 MockGetResponse(t) 51 52 actual, err := apiversions.Get(client.ServiceClient(), "v1").Extract() 53 th.AssertNoErr(t, err) 54 55 expected := apiversions.APIVersion{ 56 ID: "v1.0", 57 Status: "CURRENT", 58 Updated: "2012-01-04T11:33:21Z", 59 } 60 61 th.AssertEquals(t, actual.ID, expected.ID) 62 th.AssertEquals(t, actual.Status, expected.Status) 63 th.AssertEquals(t, actual.Updated, expected.Updated) 64 }