smobilpay.TestSubscriptionService_Get   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 32
Code Lines 21

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 21
nop 1
dl 0
loc 32
rs 9.376
c 0
b 0
f 0
1
package smobilpay
2
3
import (
4
	"context"
5
	"github.com/NdoleStudio/smobilpay-go/internal/helpers"
6
	"github.com/NdoleStudio/smobilpay-go/internal/stubs"
7
	"github.com/stretchr/testify/assert"
8
	"net/http"
9
	"testing"
10
)
11
12
func TestSubscriptionService_Get(t *testing.T) {
13
	// Setup
14
	t.Parallel()
15
16
	// Arrange
17
	server := helpers.MakeTestServer(http.StatusOK, stubs.SubscriptionGet())
18
	accessToken := "6B352110-4716-11ED-963F-0800200C9A66"
19
	client := New(
20
		WithBaseURL(server.URL),
21
		WithAccessToken(accessToken),
22
		WithAccessSecret("1B875FB0-4717-11ED-963F-0800200C9A66"),
23
	)
24
	nonce := "95cdf110-4614-4d95-b6c2-f14fe01c4995"
25
	params := &SubscriptionGetParams{
26
		ServiceID:     "10042",
27
		Merchant:      "CMENEOPREPAID",
28
		ServiceNumber: "500000001",
29
	}
30
31
	// Act
32
	subscription, response, err := client.Subscription.Get(context.Background(), params, WithRequestNonce(nonce))
33
34
	// Assert
35
	assert.Nil(t, err)
36
	assert.Equal(t, http.StatusOK, response.HTTPResponse.StatusCode)
37
	assert.Equal(t, 1, len(subscription))
38
	assert.Equal(t, params.ServiceID, subscription[0].ServiceID)
39
	assert.Equal(t, params.Merchant, subscription[0].Merchant)
40
	assert.Equal(t, params.ServiceNumber, subscription[0].ServiceNumber)
41
42
	// Teardown
43
	server.Close()
44
}
45