FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
godo/image_actions_test.go at main · digitalocean/godo · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
digitalocean
/
godo
Public
Notifications
You must be signed in to change notification settings
Fork
386
Star
1.5k
Code
Issues
16
Pull requests
25
Actions
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
godo
/
image_actions_test.go
Copy path
More file actions
More file actions
Latest commit
History
History
History
97 lines (76 loc) · 2.36 KB
Breadcrumbs
godo
/
image_actions_test.go
Copy path
File metadata and controls
97 lines (76 loc) · 2.36 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
85
86
87
88
89
90
91
92
93
94
95
96
97
package
godo
import
(
"encoding/json"
"fmt"
"net/http"
"reflect"
"testing"
)
func
TestImageActions_Transfer
(
t
*
testing.
T
) {
setup
()
defer
teardown
()
transferRequest
:=
&
ActionRequest
{}
mux
.
HandleFunc
(
"/v2/images/12345/actions"
,
func
(
w
http.
ResponseWriter
,
r
*
http.
Request
) {
v
:=
new
(
ActionRequest
)
err
:=
json
.
NewDecoder
(
r
.
Body
).
Decode
(
v
)
if
err
!=
nil
{
t
.
Fatalf
(
"decode json: %v"
,
err
)
}
testMethod
(
t
,
r
,
http
.
MethodPost
)
if
!
reflect
.
DeepEqual
(
v
,
transferRequest
) {
t
.
Errorf
(
"Request body = %+v, expected %+v"
,
v
,
transferRequest
)
}
fmt
.
Fprintf
(
w
,
`{"action":{"status":"in-progress"}}`
)
})
transfer
,
_
,
err
:=
client
.
ImageActions
.
Transfer
(
ctx
,
12345
,
transferRequest
)
if
err
!=
nil
{
t
.
Errorf
(
"ImageActions.Transfer returned error: %v"
,
err
)
}
expected
:=
&
Action
{
Status
:
"in-progress"
}
if
!
reflect
.
DeepEqual
(
transfer
,
expected
) {
t
.
Errorf
(
"ImageActions.Transfer returned %+v, expected %+v"
,
transfer
,
expected
)
}
}
func
TestImageActions_Convert
(
t
*
testing.
T
) {
setup
()
defer
teardown
()
convertRequest
:=
&
ActionRequest
{
"type"
:
"convert"
,
}
mux
.
HandleFunc
(
"/v2/images/12345/actions"
,
func
(
w
http.
ResponseWriter
,
r
*
http.
Request
) {
v
:=
new
(
ActionRequest
)
err
:=
json
.
NewDecoder
(
r
.
Body
).
Decode
(
v
)
if
err
!=
nil
{
t
.
Fatalf
(
"decode json: %v"
,
err
)
}
testMethod
(
t
,
r
,
http
.
MethodPost
)
if
!
reflect
.
DeepEqual
(
v
,
convertRequest
) {
t
.
Errorf
(
"Request body = %+v, expected %+v"
,
v
,
convertRequest
)
}
fmt
.
Fprintf
(
w
,
`{"action":{"status":"in-progress"}}`
)
})
transfer
,
_
,
err
:=
client
.
ImageActions
.
Convert
(
ctx
,
12345
)
if
err
!=
nil
{
t
.
Errorf
(
"ImageActions.Transfer returned error: %v"
,
err
)
}
expected
:=
&
Action
{
Status
:
"in-progress"
}
if
!
reflect
.
DeepEqual
(
transfer
,
expected
) {
t
.
Errorf
(
"ImageActions.Transfer returned %+v, expected %+v"
,
transfer
,
expected
)
}
}
func
TestImageActions_Get
(
t
*
testing.
T
) {
setup
()
defer
teardown
()
mux
.
HandleFunc
(
"/v2/images/123/actions/456"
,
func
(
w
http.
ResponseWriter
,
r
*
http.
Request
) {
testMethod
(
t
,
r
,
http
.
MethodGet
)
fmt
.
Fprintf
(
w
,
`{"action":{"status":"in-progress"}}`
)
})
action
,
_
,
err
:=
client
.
ImageActions
.
Get
(
ctx
,
123
,
456
)
if
err
!=
nil
{
t
.
Errorf
(
"ImageActions.Get returned error: %v"
,
err
)
}
expected
:=
&
Action
{
Status
:
"in-progress"
}
if
!
reflect
.
DeepEqual
(
action
,
expected
) {
t
.
Errorf
(
"ImageActions.Get returned %+v, expected %+v"
,
action
,
expected
)
}
}
Back
|
FazBrowse Home
|
New Git URL