-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
206f541
commit 06bb6ac
Showing
8 changed files
with
192 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,4 +20,4 @@ vendor/ | |
# Temp file on windows | ||
$path | ||
|
||
utilities_service_test.go | ||
*e2e_test.go |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package campay | ||
|
||
import ( | ||
"context" | ||
"net/http" | ||
"testing" | ||
|
||
"github.com/NdoleStudio/campay-go-sdk/internal/helpers" | ||
"github.com/NdoleStudio/campay-go-sdk/internal/stubs" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestUtilitiesService_AirtimeTransferSync(t *testing.T) { | ||
// Setup | ||
t.Parallel() | ||
|
||
// Arrange | ||
requests := make([]*http.Request, 0) | ||
responses := [][]byte{stubs.PostTokenResponse(), stubs.PostTransferResponse(), stubs.GetPendingAirtimeTransactionResponse(), stubs.GetSuccessfullAirtimeTransactionResponse()} | ||
server := helpers.MakeRequestCapturingTestServer(http.StatusOK, responses, &requests) | ||
client := New(WithEnvironment(Environment(server.URL))) | ||
|
||
// Act | ||
transaction, _, err := client.Utilities.AirtimeTransferSync(context.Background(), &AirtimeTransferParams{ | ||
Amount: "100", | ||
To: "2376XXXXXXXXX", | ||
ExternalReference: "5577006791947779410", | ||
}) | ||
|
||
// Assert | ||
assert.Nil(t, err) | ||
|
||
assert.GreaterOrEqual(t, len(requests), 4) | ||
assert.Equal(t, &UtilitiesTransaction{ | ||
Reference: "971e32ae-bb5a-420a-a38a-c2931536609f", | ||
ExternalReference: "5577006791947779410", | ||
Status: "SUCCESSFUL", | ||
Amount: 100, | ||
Currency: "XAF", | ||
Operator: "ORANGE_CM", | ||
Code: "CP220804U0649K", | ||
Type: "AIRTIME", | ||
Reason: "", | ||
}, transaction) | ||
|
||
assert.True(t, transaction.IsSuccessfull()) | ||
assert.False(t, transaction.IsPending()) | ||
|
||
// Teardown | ||
server.Close() | ||
} |