-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi_reports_test.go
101 lines (74 loc) · 2.7 KB
/
api_reports_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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*Messaging API v3.4.3
Testing ReportsAPIService
*/
package TelstraMessaging
import (
"context"
"fmt"
"testing"
"time"
"github.com/stretchr/testify/assert"
)
func String(s string) *string {
return &s
}
func Test_TelstraMessaging_ReportsAPIService(t *testing.T) {
t.Skip("skip test")
configuration := NewConfiguration()
apiClient := NewAPIClient(configuration)
clientId := "YOUR CLIENT ID"
clientSecret := "YOUR CLIENT SECRET"
authorization, _ := GetAuthorization(apiClient, clientId, clientSecret)
t.Run("Test ReportsAPIService GetReport", func(t *testing.T) {
//t.Skip("skip test") // remove to run test
reportId := "c22d2050-eb37-11ee-ad5e-3d9263246ccb"
reportsApi := apiClient.ReportsAPI.GetReport(context.Background(), reportId, authorization)
resp, httpRes, err := reportsApi.GetReport()
if err != nil {
fmt.Println("Error:", err)
return
}
fmt.Printf("httpRes Result: %+v\n", httpRes)
fmt.Printf("resp Result: %+v\n", resp)
assert.Equal(t, 200, httpRes.StatusCode)
assert.NotEmpty(t, httpRes, "httpRes should not be empty")
assert.NoError(t, err, "Error encountered: %v", err)
assert.NotNil(t, resp, "resp should not be nil")
})
t.Run("Test ReportsAPIService GetReports", func(t *testing.T) {
//t.Skip("skip test") // remove to run test
reportsApi := apiClient.ReportsAPI.GetReports(context.Background(), authorization)
resp, httpRes, err := reportsApi.GetReports()
if err != nil {
fmt.Println("Error:", err)
return
}
fmt.Printf("httpRes Result: %+v\n", httpRes)
fmt.Printf("resp Result: %+v\n", resp)
assert.Equal(t, 200, httpRes.StatusCode)
assert.NotEmpty(t, httpRes, "httpRes should not be empty")
assert.NoError(t, err, "Error encountered: %v", err)
assert.NotNil(t, resp, "resp should not be nil")
})
t.Run("Test ReportsAPIService MessagesReport", func(t *testing.T) {
//t.Skip("skip test") // remove to run test
now := time.Now()
threeDaysAgo := now.AddDate(0, 0, -3)
oneDayAgo := now.AddDate(0, 0, -1)
threeDaysAgoFormatted := threeDaysAgo.Format("2006-01-02")
oneDayAgoFormatted := oneDayAgo.Format("2006-01-02")
messageReportRequest := NewMessagesReportRequest(threeDaysAgoFormatted, oneDayAgoFormatted)
reportsApi := apiClient.ReportsAPI.MessagesReport(context.Background(), authorization)
resp, httpRes, err := reportsApi.MessagesReport(*messageReportRequest)
if err != nil {
fmt.Println("Error:", err)
return
}
fmt.Printf("httpRes Result: %+v\n", httpRes)
fmt.Printf("resp Result: %+v\n", resp)
assert.Equal(t, 201, httpRes.StatusCode)
assert.NotEmpty(t, httpRes, "httpRes should not be empty")
assert.NoError(t, err, "Error encountered: %v", err)
assert.NotNil(t, resp, "resp should not be nil")
})
}