-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlast_payment_test.go
44 lines (37 loc) · 1.19 KB
/
last_payment_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package sendios
import (
"fmt"
"github.com/joho/godotenv"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"os"
"strconv"
"testing"
"time"
)
func TestSendLastPayment(t *testing.T) {
require.NoError(t, godotenv.Load())
require.NotEmpty(t, os.Getenv("SENDIOS_PROJECT"))
require.NotEmpty(t, os.Getenv("SENDIOS_CLIENT_ID"))
require.NotEmpty(t, os.Getenv("SENDIOS_TOKEN"))
require.NotEmpty(t, os.Getenv("TEST_EMAIL"))
project, err := strconv.Atoi(os.Getenv("SENDIOS_PROJECT"))
require.NoError(t, err)
client, err := strconv.Atoi(os.Getenv("SENDIOS_CLIENT_ID"))
require.NoError(t, err)
c := New(project, client, os.Getenv("SENDIOS_TOKEN"))
c.DebugRequests = true
payment, err := c.SendLastPaymentByEmail(os.Getenv("TEST_EMAIL"), Payment{
StartDate: fmt.Sprintf("%d", time.Now().AddDate(0, -1, 0).Unix()),
ExpireDate: fmt.Sprintf("%d", time.Now().AddDate(0, 1, 0).Unix()),
TotalCount: "1",
PaymentType: "",
Amount: "",
})
require.NoError(t, err)
require.NotNil(t, payment)
assert.Equal(t, "done", payment.Data.Message)
assert.True(t, payment.Data.Status)
_, err = time.Parse("2006-01-2 15:04:05.000000", payment.Data.Date)
require.NoError(t, err)
}