This repository has been archived by the owner on Jun 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
slot_test.go
60 lines (52 loc) · 1.62 KB
/
slot_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
package drs
import (
"net/http"
"testing"
"github.com/stretchr/testify/assert"
)
func TestSlotStatus(t *testing.T) {
ConfigSetup()
badInput := SlotStatus{
ExpectedReplenishmentDate: "2003-12-28 19:00:00",
LastUseDate: "1985-01-13 05:05:04",
}
goodInput := SlotStatus{
RemainingQuantityInUnit: 3.5,
OriginalQuantityInUnit: 10.0,
TotalQuantityOnHand: 0,
ExpectedReplenishmentDate: "2015-12-28T10:00:00Z",
LastUseDate: "2015-12-21T10:00:00Z",
}
result, err := ReportSlotStatus("", "", &goodInput)
assert.NotNil(t, err)
assert.False(t, result)
if apiError, ok := err.(*APIError); ok {
assert.Equal(t, http.StatusBadRequest, apiError.Code)
}
result, err = ReportSlotStatus("TEST", "", &goodInput)
assert.NotNil(t, err)
assert.False(t, result)
if apiError, ok := err.(*APIError); ok {
assert.Equal(t, http.StatusBadRequest, apiError.Code)
}
result, err = ReportSlotStatus("TEST", "TEST", &badInput)
assert.NotNil(t, err)
assert.False(t, result)
if apiError, ok := err.(*APIError); ok {
assert.Equal(t, http.StatusBadRequest, apiError.Code)
}
//make expected fine but last still bad
badInput.ExpectedReplenishmentDate = "2015-12-28T10:00:00Z"
result, err = ReportSlotStatus("TEST", "TEST", &badInput)
assert.NotNil(t, err)
assert.False(t, result)
if apiError, ok := err.(*APIError); ok {
assert.Equal(t, http.StatusBadRequest, apiError.Code)
}
result, err = ReportSlotStatus("TEST", "TEST", &goodInput)
assert.Nil(t, err)
assert.True(t, result)
result, err = ReportSlotStatus("random", "random", &goodInput)
assert.NotNil(t, err)
assert.False(t, result)
}