-
Notifications
You must be signed in to change notification settings - Fork 2
/
transactions_service_test.go
52 lines (39 loc) · 1.19 KB
/
transactions_service_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
package flutterwave
import (
"context"
"github.com/NdoleStudio/flutterwave-go/internal/helpers"
"github.com/NdoleStudio/flutterwave-go/internal/stubs"
"github.com/stretchr/testify/assert"
"net/http"
"testing"
)
func TestTransactionsService_Refund(t *testing.T) {
// Setup
t.Parallel()
// Arrange
server := helpers.MakeTestServer(http.StatusOK, string(stubs.TransactionRefundResponse()))
client := New(WithBaseURL(server.URL))
// Act
refund, response, err := client.Transactions.Refund(context.Background(), 123, 200)
// Assert
assert.Nil(t, err)
assert.Equal(t, http.StatusOK, response.HTTPResponse.StatusCode)
assert.Equal(t, stubs.TransactionRefundResponse(), *response.Body)
assert.Equal(t, 75923, refund.Data.ID)
// Teardown
server.Close()
}
func TestTransactionsService_RefundWithError(t *testing.T) {
// Setup
t.Parallel()
// Arrange
server := helpers.MakeTestServer(http.StatusInternalServerError, "")
client := New(WithBaseURL(server.URL))
// Act
_, response, err := client.Transactions.Refund(context.Background(), 123, 200)
// Assert
assert.NotNil(t, err)
assert.Equal(t, http.StatusInternalServerError, response.HTTPResponse.StatusCode)
// Teardown
server.Close()
}