-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_test.go
58 lines (49 loc) · 1.16 KB
/
main_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
package mss
import (
"context"
"net/http"
"os"
"testing"
"time"
"github.com/bookingsuedtirol/mss-go/request"
)
var client = NewClient(
http.Client{
Timeout: 20 * time.Second,
},
Credentials{
User: os.Getenv("MSS_USER"),
Password: os.Getenv("MSS_PASSWORD"),
Source: os.Getenv("MSS_SOURCE"),
},
)
func TestEnvVariablesAreDefined(t *testing.T) {
if c := client.credentials; c.User == "" || c.Password == "" || c.Source == "" {
t.Error("env variables MSS_USER etc. not set")
}
}
func TestSimpleMssCall(t *testing.T) {
responseRoot, err := client.Request(context.Background(),
func(requestRoot request.Root) request.Root {
requestRoot.Header.Method = request.MethodGetHotelList
requestRoot.Request = request.Request{
Search: &request.Search{
IDs: []int{9002},
},
Options: &request.Options{
HotelDetails: request.HotelDetailsBasicInfo |
request.HotelDetailsCoordinates,
},
}
return requestRoot
},
)
if err != nil {
panic(err)
}
want := "Testhotel Webseitentool HGV (hotelhgv.it)"
got := responseRoot.Result.Hotels[0].Name
if got != want {
t.Errorf("failed, want \"%v\", got \"%v\"", want, got)
}
}