topup_service_test.go   A
last analyzed

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 25
dl 0
loc 40
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A smobilpay.TestTopupService_GetPackages 0 28 1
1
package smobilpay
2
3
import (
4
	"context"
5
	"net/http"
6
	"testing"
7
8
	"github.com/NdoleStudio/smobilpay-go/internal/helpers"
9
	"github.com/NdoleStudio/smobilpay-go/internal/stubs"
10
	"github.com/stretchr/testify/assert"
11
)
12
13
func TestTopupService_GetPackages(t *testing.T) {
14
	// Setup
15
	t.Parallel()
16
17
	// Arrange
18
	server := helpers.MakeTestServer(http.StatusOK, stubs.TopupGetPackagesOk())
19
	accessToken := "6B352110-4716-11ED-963F-0800200C9A66"
20
	client := New(
21
		WithBaseURL(server.URL),
22
		WithAccessToken(accessToken),
23
		WithAccessSecret("1B875FB0-4717-11ED-963F-0800200C9A66"),
24
	)
25
	nonce := "95cdf110-4614-4d95-b6c2-f14fe01c4995"
26
27
	// Act
28
	topupPackages, response, err := client.Topup.GetPackages(
29
		context.Background(),
30
		"1234",
31
		WithRequestNonce(nonce),
32
	)
33
34
	// Assert
35
	assert.Nil(t, err)
36
	assert.Equal(t, http.StatusOK, response.HTTPResponse.StatusCode)
37
	assert.Equal(t, 2, len(topupPackages))
38
39
	// Teardown
40
	server.Close()
41
}
42