Skip to content
This repository was archived by the owner on Aug 1, 2023. It is now read-only.

Commit dca55ac

Browse files
James FisherSamuel Ortiz
authored andcommitted
test get image; currently failing
1 parent 16d90e4 commit dca55ac

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed

openstack/imageservice/v2/fixtures.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,34 @@ func HandleImageCreationSuccessfully(t *testing.T) {
4949
}`)
5050
})
5151
}
52+
53+
func HandleImageGetSuccessfully(t *testing.T) {
54+
th.Mux.HandleFunc("/images/1bea47ed-f6a9-463b-b423-14b9cca9ad27", func(w http.ResponseWriter, r *http.Request) {
55+
th.TestMethod(t, r, "GET")
56+
th.TestHeader(t, r, "X-Auth-Token", fakeclient.TokenID)
57+
58+
w.WriteHeader(http.StatusOK)
59+
w.Header().Add("Content-Type", "application/json")
60+
fmt.Fprintf(w, `{
61+
"status": "active",
62+
"name": "cirros-0.3.2-x86_64-disk",
63+
"tags": [],
64+
"container_format": "bare",
65+
"created_at": "2014-05-05T17:15:10Z",
66+
"disk_format": "qcow2",
67+
"updated_at": "2014-05-05T17:15:11Z",
68+
"visibility": "public",
69+
"self": "/v2/images/1bea47ed-f6a9-463b-b423-14b9cca9ad27",
70+
"min_disk": 0,
71+
"protected": false,
72+
"id": "1bea47ed-f6a9-463b-b423-14b9cca9ad27",
73+
"file": "/v2/images/1bea47ed-f6a9-463b-b423-14b9cca9ad27/file",
74+
"checksum": "64d7c1cd2b6f60c92c14662941cb7913",
75+
"owner": "5ef70662f8b34079a6eddb8da9d75fe8",
76+
"size": 13167616,
77+
"min_ram": 0,
78+
"schema": "/v2/schemas/image",
79+
"virtual_size": "None"
80+
}`)
81+
})
82+
}

openstack/imageservice/v2/requests_test.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,37 @@ func TestCreateImage(t *testing.T) {
3636

3737
th.AssertDeepEquals(t, &expectedImage, actualImage)
3838
}
39+
40+
func TestGetImage(t *testing.T) {
41+
th.SetupHTTP()
42+
defer th.TeardownHTTP()
43+
44+
HandleImageGetSuccessfully(t)
45+
46+
actualImage, err := Get(fakeclient.ServiceClient(), "1bea47ed-f6a9-463b-b423-14b9cca9ad27").Extract()
47+
48+
th.AssertNoErr(t, err)
49+
50+
expectedImage := Image{
51+
Id: "1bea47ed-f6a9-463b-b423-14b9cca9ad27",
52+
Name: "cirros-0.3.2-x86_64-disk",
53+
Status: ImageStatusActive,
54+
Tags: []string{},
55+
56+
ContainerFormat: "bare",
57+
DiskFormat: "qcow2",
58+
59+
MinDiskGigabytes: 0,
60+
MinRamMegabytes: 0,
61+
62+
Owner: "5ef70662f8b34079a6eddb8da9d75fe8",
63+
64+
Protected: false,
65+
Visibility: ImageVisibilityPublic,
66+
67+
Checksum: "64d7c1cd2b6f60c92c14662941cb7913",
68+
SizeBytes: 13167616,
69+
}
70+
71+
th.AssertDeepEquals(t, &expectedImage, actualImage)
72+
}

0 commit comments

Comments
 (0)