forked from vultr/govultr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
marketplace_test.go
53 lines (47 loc) · 1.43 KB
/
marketplace_test.go
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
package govultr
import (
"fmt"
"net/http"
"reflect"
"testing"
)
func TestMarketplaceServiceHandler_ListAppVariables(t *testing.T) {
setup()
defer teardown()
mux.HandleFunc(fmt.Sprintf("/v2/marketplace/apps/%s/variables", "testimage"), func(writer http.ResponseWriter, request *http.Request) {
response := `{
"variables": [
{
"name": "some_required_variable",
"description": "This is an example of a required user-supplied variable for this Marketplace app.",
"required": true
},
{
"name": "some_optional_variable",
"description": "This is an example of an optional user-supplied variable for this Marketplace app.",
"required": false
}
]
}`
fmt.Fprint(writer, response)
})
variables, _, err := client.Marketplace.ListAppVariables(ctx, "testimage")
if err != nil {
t.Errorf("Marketplace.ListAppVariables returned %+v", err)
}
expected := []MarketplaceAppVariable{
{
Name: "some_required_variable",
Description: "This is an example of a required user-supplied variable for this Marketplace app.",
Required: BoolToBoolPtr(true),
},
{
Name: "some_optional_variable",
Description: "This is an example of an optional user-supplied variable for this Marketplace app.",
Required: BoolToBoolPtr(false),
},
}
if !reflect.DeepEqual(variables, expected) {
t.Errorf("Marketplace.ListAppVariables returned %+v, expected %+v", variables, expected)
}
}