-
Notifications
You must be signed in to change notification settings - Fork 0
/
schedule-feed_test.go
42 lines (34 loc) · 1.44 KB
/
schedule-feed_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
package main
import (
"encoding/json"
"io/ioutil"
"path/filepath"
"testing"
)
func TestUnmarshalJSONAndAugmentJSONSchedule(t *testing.T) {
// Read the JSON file
jsonData, err := ioutil.ReadFile(filepath.Join("test-fixtures", "feed.json"))
if err != nil {
t.Fatal("Failed to read JSON file:", err)
}
var scheduleFeedRecord ScheduleFeedRecord
// Unmarshal the JSON data into the struct
if err := json.Unmarshal(jsonData, &scheduleFeedRecord); err != nil {
t.Fatal("Failed to unmarshal JSON:", err)
}
schedule := scheduleFeedRecord.JSONScheduleV1.ToSchedule()
// Call AugmentSchedule() on the result
schedule.AugmentSchedule()
// Assert that TransactionType is "Create"
expect(schedule.TransactionType, "TransactionType", "Create", t)
expect(schedule.CIFStpIndicator, "CIFStpIndicator", "P", t)
expect(schedule.CIFPowerType, "CIFPowerType", "DMU", t)
expect(schedule.CIFTrainCategory, "CIFTrainCategory", "OO", t)
expect(schedule.SignallingID, "SignallingID", "2A20", t)
expect(schedule.ScheduleDaysRuns, "ScheduleDaysRuns", "0000001", t)
expect(schedule.ScheduleStartDate, "ScheduleStartDate", "2023-05-21", t)
expect(schedule.ScheduleEndDate, "ScheduleEndDate", "2023-12-03", t)
expect(schedule.ScheduleLocation[0].TiplocCode, "Location 0 TiplocCode", "DRBY", t)
expect(schedule.ScheduleLocation[0].RecordIdentity, "Location 0 LocationType", "LO", t)
expect(schedule.ScheduleLocation[0].Departure, "Location 0 Departure", "0756", t)
}