-
Notifications
You must be signed in to change notification settings - Fork 127
/
Copy pathapp_features_test.go
57 lines (53 loc) · 1.6 KB
/
app_features_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
54
55
56
57
package client
import (
"context"
"net/http"
"testing"
"github.com/cloudfoundry/go-cfclient/v3/testutil"
)
func TestAppFeatures(t *testing.T) {
g := testutil.NewObjectJSONGenerator()
appFeature := g.AppFeature().JSON
tests := []RouteTest{
{
Description: "Get SSH app feature",
Route: testutil.MockRoute{
Method: "GET",
Endpoint: "/v3/apps/1cb006ee-fb05-47e1-b541-c34179ddc446/features/ssh",
Output: g.Single(appFeature),
Status: http.StatusOK},
Expected: appFeature,
Action: func(c *Client, t *testing.T) (any, error) {
return c.AppFeatures.GetSSH(context.Background(), "1cb006ee-fb05-47e1-b541-c34179ddc446")
},
},
{
Description: "List all app features",
Route: testutil.MockRoute{
Method: "GET",
Endpoint: "/v3/apps/1cb006ee-fb05-47e1-b541-c34179ddc446/features",
Output: g.SinglePaged(appFeature),
Status: http.StatusOK},
Expected: g.Array(appFeature),
Action: func(c *Client, t *testing.T) (any, error) {
f, _, err := c.AppFeatures.List(context.Background(), "1cb006ee-fb05-47e1-b541-c34179ddc446")
return f, err
},
},
{
Description: "Update SSH app feature",
Route: testutil.MockRoute{
Method: "PATCH",
Endpoint: "/v3/apps/1cb006ee-fb05-47e1-b541-c34179ddc446/features/ssh",
Output: g.Single(appFeature),
Status: http.StatusOK,
PostForm: `{ "enabled": false }`,
},
Expected: appFeature,
Action: func(c *Client, t *testing.T) (any, error) {
return c.AppFeatures.UpdateSSH(context.Background(), "1cb006ee-fb05-47e1-b541-c34179ddc446", false)
},
},
}
ExecuteTests(tests, t)
}