-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstock_test.go
48 lines (40 loc) · 1.01 KB
/
stock_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
package goafterbuy_test
import (
"github.com/jjideenschmiede/goafterbuy"
"testing"
)
// TestStock is to test the stock function
func TestStock(t *testing.T) {
// Define variables for request
partnerToken := ""
accountToken := ""
// Define stock body
body := goafterbuy.StockBody{
Request: goafterbuy.StockRequest{
AfterbuyGlobal: goafterbuy.AfterbuyGlobal{
PartnerToken: partnerToken,
AccountToken: accountToken,
CallName: "GetShopProducts",
DetailLevel: 2,
ErrorLanguage: "DE",
},
Products: goafterbuy.StockProducts{
Product: goafterbuy.StockProduct{
ProductId: 0,
},
},
},
}
// Get stock
stock, err := goafterbuy.Stock(body)
if err != nil {
t.Fatal(err)
}
// Check the results
var results []string
for _, value := range stock.Result.Products.Product {
results = append(results, value.Name)
}
// Print output
t.Logf("The stock were read. There are \"%d\" products. Here you can see the names of the products read out: %v.", len(results), results)
}