Compare commits
No commits in common. "d0c9250afa25d583067d9b96398034a346e9c2a8" and "4a7bcd7f80f3183963afe18f4738f655810ab111" have entirely different histories.
d0c9250afa
...
4a7bcd7f80
|
@ -25,8 +25,6 @@ func ConvertServiceType(input *upstreamApi.JsonScheduleV1, vstp bool) (*database
|
||||||
Stops: parseStops(&input.ScheduleSegment.ScheduleLocation),
|
Stops: parseStops(&input.ScheduleSegment.ScheduleLocation),
|
||||||
}
|
}
|
||||||
|
|
||||||
// New struct tags are not yet parsed. Ensure all struct tags are present.
|
|
||||||
|
|
||||||
return &output, nil
|
return &output, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,34 +49,7 @@ func parseSpeed(CIFSpeed *string) int32 {
|
||||||
return int32(speed)
|
return int32(speed)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Not tested
|
|
||||||
func parseStops(input *[]upstreamApi.CifScheduleLocation) []database.Stop {
|
func parseStops(input *[]upstreamApi.CifScheduleLocation) []database.Stop {
|
||||||
output := make([]database.Stop, 0, len(*input))
|
output := make([]database.Stop, 0, len(*input))
|
||||||
|
|
||||||
for _, item := range *input {
|
|
||||||
stop := database.Stop{
|
|
||||||
PublicDeparture: item.PublicDeparture,
|
|
||||||
PublicArrival: item.PublicArrival,
|
|
||||||
WttDeparture: item.Departure,
|
|
||||||
WttArrival: item.Arrival,
|
|
||||||
Pass: item.Pass,
|
|
||||||
Platform: item.Platform,
|
|
||||||
ArrLine: item.Path,
|
|
||||||
DepLine: item.Line,
|
|
||||||
Tiploc: item.TiplocCode,
|
|
||||||
IsPublic: isPublic(&item),
|
|
||||||
}
|
|
||||||
|
|
||||||
output = append(output, stop)
|
|
||||||
}
|
|
||||||
|
|
||||||
return output
|
return output
|
||||||
}
|
}
|
||||||
|
|
||||||
// Not tested
|
|
||||||
func isPublic(input *upstreamApi.CifScheduleLocation) bool {
|
|
||||||
if input.PublicArrival == "" && input.PublicDeparture == "" {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
|
@ -4,24 +4,28 @@ import "testing"
|
||||||
|
|
||||||
func TestParseSpeed(t *testing.T) {
|
func TestParseSpeed(t *testing.T) {
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
input string
|
input *string
|
||||||
expected int32
|
expected int32
|
||||||
}{
|
}{
|
||||||
{"075", 75},
|
{strPtr("075"), 75},
|
||||||
{"125", 125},
|
{strPtr("125"), 125},
|
||||||
{"40", 40},
|
{strPtr("40"), 40},
|
||||||
{"040", 40},
|
{strPtr("040"), 40},
|
||||||
{"134", 60},
|
{strPtr("134"), 60},
|
||||||
{"179", 80},
|
{strPtr("179"), 80},
|
||||||
{"186", 186},
|
{strPtr("186"), 186},
|
||||||
{"417", 186},
|
{strPtr("417"), 186},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
result := parseSpeed(&tc.input)
|
result := parseSpeed(tc.input)
|
||||||
|
|
||||||
if result != tc.expected {
|
if result != tc.expected {
|
||||||
t.Errorf("For speed: %s, expected: %d, but got: %d", tc.input, tc.expected, result)
|
t.Errorf("For speed: %s, expected: %d, but got: %d", tc.input, tc.expected, result)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func strPtr(s string) *string {
|
||||||
|
return &s
|
||||||
|
}
|
||||||
|
|
2
go.mod
2
go.mod
|
@ -3,7 +3,7 @@ module git.fjla.uk/owlboard/timetable-mgr
|
||||||
go 1.21
|
go 1.21
|
||||||
|
|
||||||
require (
|
require (
|
||||||
git.fjla.uk/owlboard/go-types v0.0.0-20240407202712-e58d7d1d9aa9
|
git.fjla.uk/owlboard/go-types v0.0.0-20240405194933-7dafca950460
|
||||||
github.com/go-stomp/stomp/v3 v3.0.5
|
github.com/go-stomp/stomp/v3 v3.0.5
|
||||||
go.mongodb.org/mongo-driver v1.12.0
|
go.mongodb.org/mongo-driver v1.12.0
|
||||||
go.uber.org/zap v1.24.0
|
go.uber.org/zap v1.24.0
|
||||||
|
|
2
go.sum
2
go.sum
|
@ -6,8 +6,6 @@ git.fjla.uk/owlboard/go-types v0.0.0-20240403200521-41796e25b6c3 h1:veGmL8GeWsgG
|
||||||
git.fjla.uk/owlboard/go-types v0.0.0-20240403200521-41796e25b6c3/go.mod h1:kG+BX9UF+yJaAVnln/QSKlTdrtKRRReezMeSk1ZLMzY=
|
git.fjla.uk/owlboard/go-types v0.0.0-20240403200521-41796e25b6c3/go.mod h1:kG+BX9UF+yJaAVnln/QSKlTdrtKRRReezMeSk1ZLMzY=
|
||||||
git.fjla.uk/owlboard/go-types v0.0.0-20240405194933-7dafca950460 h1:39vcejk0MzZIL2WdriKSfcDoCc/0NWzZMncHqw5ctbY=
|
git.fjla.uk/owlboard/go-types v0.0.0-20240405194933-7dafca950460 h1:39vcejk0MzZIL2WdriKSfcDoCc/0NWzZMncHqw5ctbY=
|
||||||
git.fjla.uk/owlboard/go-types v0.0.0-20240405194933-7dafca950460/go.mod h1:kG+BX9UF+yJaAVnln/QSKlTdrtKRRReezMeSk1ZLMzY=
|
git.fjla.uk/owlboard/go-types v0.0.0-20240405194933-7dafca950460/go.mod h1:kG+BX9UF+yJaAVnln/QSKlTdrtKRRReezMeSk1ZLMzY=
|
||||||
git.fjla.uk/owlboard/go-types v0.0.0-20240407202712-e58d7d1d9aa9 h1:aNxMYEsbBkFx9b9J8zR1m08KL3JG9b0rPHszryKm5uk=
|
|
||||||
git.fjla.uk/owlboard/go-types v0.0.0-20240407202712-e58d7d1d9aa9/go.mod h1:kG+BX9UF+yJaAVnln/QSKlTdrtKRRReezMeSk1ZLMzY=
|
|
||||||
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
|
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
|
||||||
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
|
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
|
Loading…
Reference in New Issue