This repository has been archived by the owner on Oct 13, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 273
/
itinerary_test.go
75 lines (64 loc) · 1.8 KB
/
itinerary_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
package shipping
import (
"reflect"
"testing"
)
func TestItinerary_CreateEmpty(t *testing.T) {
i := Itinerary{}
var legs []Leg
if !reflect.DeepEqual(i.Legs, legs) {
t.Errorf("should be equal")
}
if i.InitialDepartureLocation() != "" {
t.Errorf("InitialDepartureLocation() = %s; want = %s",
i.InitialDepartureLocation(), "")
}
if i.FinalArrivalLocation() != "" {
t.Errorf("FinalArrivalLocation() = %s; want = %s",
i.FinalArrivalLocation(), "")
}
}
func TestItinerary_IsExpected_EmptyItinerary(t *testing.T) {
i := Itinerary{}
e := HandlingEvent{}
if got, want := i.IsExpected(e), true; got != want {
t.Errorf("IsExpected() = %v; want = %v", got, want)
}
}
type eventExpectedTest struct {
act HandlingActivity
exp bool
}
var eventExpectedTests = []eventExpectedTest{
{HandlingActivity{}, true},
{HandlingActivity{Type: Receive, Location: SESTO}, true},
{HandlingActivity{Type: Receive, Location: AUMEL}, false},
{HandlingActivity{Type: Load, Location: AUMEL, VoyageNumber: "001A"}, true},
{HandlingActivity{Type: Load, Location: CNHKG, VoyageNumber: "001A"}, false},
{HandlingActivity{Type: Unload, Location: CNHKG, VoyageNumber: "001A"}, true},
{HandlingActivity{Type: Unload, Location: SESTO, VoyageNumber: "001A"}, false},
{HandlingActivity{Type: Claim, Location: CNHKG}, true},
{HandlingActivity{Type: Claim, Location: SESTO}, false},
}
func TestItinerary_IsExpected(t *testing.T) {
i := Itinerary{Legs: []Leg{
{
VoyageNumber: "001A",
LoadLocation: SESTO,
UnloadLocation: AUMEL,
},
{
VoyageNumber: "001A",
LoadLocation: AUMEL,
UnloadLocation: CNHKG,
},
}}
for _, tt := range eventExpectedTests {
e := HandlingEvent{
Activity: tt.act,
}
if got := i.IsExpected(e); got != tt.exp {
t.Errorf("IsExpected() = %v; want = %v", got, tt.exp)
}
}
}