Skip to content

Commit 1f37cf4

Browse files
committed
create mocks for sdk functions
1 parent c821fd2 commit 1f37cf4

File tree

3 files changed

+398
-2
lines changed

3 files changed

+398
-2
lines changed

sdk/api_client_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ func TestAPIClient_PostPolicy(t *testing.T) {
607607
httpClient := &dphttp.ClienterMock{
608608
DoFunc: func(ctx context.Context, req *http.Request) (*http.Response, error) {
609609
return &http.Response{
610-
StatusCode: http.StatusOK,
610+
StatusCode: http.StatusCreated,
611611
Body: io.NopCloser(bytes.NewReader(bresult)),
612612
}, nil
613613
},
@@ -653,7 +653,7 @@ func TestAPIClient_PostPolicy_BadRequest(t *testing.T) {
653653
})
654654
}
655655

656-
func TestAPIClient_PostPolicy_Non200ResponseCodeReturned(t *testing.T) {
656+
func TestAPIClient_PostPolicy_Non201ResponseCodeReturned(t *testing.T) {
657657
ctx := context.Background()
658658

659659
Convey("Given a mock http client that returns a response code 400", t, func() {

sdk/interface.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package sdk
2+
3+
import (
4+
"context"
5+
6+
"github.com/ONSdigital/dp-permissions-api/models"
7+
)
8+
9+
//go:generate moq -out ./mocks/client.go -pkg mocks . Clienter
10+
11+
type Clienter interface {
12+
GetRoles(ctx context.Context) (*models.Roles, error)
13+
GetRole(ctx context.Context, id string) (*models.Roles, error)
14+
PostPolicy(ctx context.Context, policy models.PolicyInfo) (*models.Policy, error)
15+
DeletePolicy(ctx context.Context, id string) error
16+
GetPolicy(ctx context.Context, id string) (*models.Policy, error)
17+
PutPolicy(ctx context.Context, id string, policy models.Policy) error
18+
GetPermissionsBundle(ctx context.Context) (Bundle, error)
19+
}

0 commit comments

Comments
 (0)