for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
package smobilpay
import (
"context"
"net/http"
"testing"
"github.com/NdoleStudio/smobilpay-go/internal/helpers"
"github.com/NdoleStudio/smobilpay-go/internal/stubs"
"github.com/stretchr/testify/assert"
)
func TestTopupService_GetPackages(t *testing.T) {
// Setup
t.Parallel()
// Arrange
server := helpers.MakeTestServer(http.StatusOK, stubs.TopupGetPackagesOk())
accessToken := "6B352110-4716-11ED-963F-0800200C9A66"
client := New(
WithBaseURL(server.URL),
WithAccessToken(accessToken),
WithAccessSecret("1B875FB0-4717-11ED-963F-0800200C9A66"),
nonce := "95cdf110-4614-4d95-b6c2-f14fe01c4995"
// Act
topupPackages, response, err := client.Topup.GetPackages(
context.Background(),
"1234",
WithRequestNonce(nonce),
// Assert
assert.Nil(t, err)
assert.Equal(t, http.StatusOK, response.HTTPResponse.StatusCode)
assert.Equal(t, 2, len(topupPackages))
// Teardown
server.Close()
}