Skip to content

Commit

Permalink
test: ✅ Fixed tests
Browse files Browse the repository at this point in the history
Signed-off-by: Alessandro Sanino <[email protected]>
  • Loading branch information
saniales committed Jan 4, 2024
1 parent 23c1c2d commit e3dbb43
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go

name: Go
name: Build and Test Library

on:
push:
Expand Down
13 changes: 7 additions & 6 deletions tx_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package coinpayments_test

import (
"fmt"
"testing"

"github.com/tryvium-travels/go-coinpayments"
Expand All @@ -13,26 +12,28 @@ func TestCallGetTxInfo(t *testing.T) {
t.Fatal("should have instantiated a new client with valid configuration")
}

resp, err := client.CallGetTxInfo(&coinpayments.TxInfoRequest{TxID: "CPCH3A2HBY7R92IOCQNYPL1G8X", Full: "0"})
resp, err := client.CallGetTxInfo(&coinpayments.TxInfoRequest{TxID: "CPHB0ZYSLG1TRNVDGKPMINAYFW", Full: "0"})
if err != nil {
t.Fatal("error getting tx info ", err)
}

fmt.Printf("%+v\n", resp)
if coin, exists := resp.Result["coin"].(string); !exists || coin != "SYS" {
t.Fatalf("error in tx: Expected coin to be SYS, found %s", coin)
}
}

func TestCallCreateTransaction(t *testing.T) {
client, err := testClient()
if err != nil {
t.Fatalf("Should have instantiated a new client with valid config and http client, but it threw error: %s", err.Error())
}

resp, err := client.CallCreateTransaction(&coinpayments.TransactionRequest{Amount: "100", Currency1: "USD", Currency2: "BTC", BuyerEmail: "[email protected]"})
resp, err := client.CallCreateTransaction(&coinpayments.TransactionRequest{Amount: "100", Currency1: "USD", Currency2: "BTC", BuyerEmail: "[email protected]"})
if err != nil {
t.Fatalf("Could not call create transaction: %s", err.Error())
}

_, err = client.CallGetTxInfo(&coinpayments.TxInfoRequest{TxID: resp.TxnID})

if err != nil {
t.Fatalf("Could not call get tx info: %s", err.Error())
}
Expand All @@ -59,7 +60,7 @@ func TestCallGetDepositAddress(t *testing.T) {
t.Fatalf("Should have instantiated a new client with valid config and http client, but it threw error: %s", err.Error())
}

_, err = client.CallGetDepositAddress(&coinpayments.DepositAddressRequest{Currency: "BTC"})
_, err = client.CallGetDepositAddress(&coinpayments.DepositAddressRequest{Currency: "SYS"})

if err != nil {
t.Fatalf("Could not call get callback address: %s", err.Error())
Expand Down

0 comments on commit e3dbb43

Please sign in to comment.