Compare commits

..

No commits in common. "d0c9250afa25d583067d9b96398034a346e9c2a8" and "4a7bcd7f80f3183963afe18f4738f655810ab111" have entirely different histories.

4 changed files with 15 additions and 42 deletions

View File

@ -25,8 +25,6 @@ func ConvertServiceType(input *upstreamApi.JsonScheduleV1, vstp bool) (*database
Stops: parseStops(&input.ScheduleSegment.ScheduleLocation),
}
// New struct tags are not yet parsed. Ensure all struct tags are present.
return &output, nil
}
@ -51,34 +49,7 @@ func parseSpeed(CIFSpeed *string) int32 {
return int32(speed)
}
// Not tested
func parseStops(input *[]upstreamApi.CifScheduleLocation) []database.Stop {
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
}
// Not tested
func isPublic(input *upstreamApi.CifScheduleLocation) bool {
if input.PublicArrival == "" && input.PublicDeparture == "" {
return false
}
return true
}

View File

@ -4,24 +4,28 @@ import "testing"
func TestParseSpeed(t *testing.T) {
testCases := []struct {
input string
input *string
expected int32
}{
{"075", 75},
{"125", 125},
{"40", 40},
{"040", 40},
{"134", 60},
{"179", 80},
{"186", 186},
{"417", 186},
{strPtr("075"), 75},
{strPtr("125"), 125},
{strPtr("40"), 40},
{strPtr("040"), 40},
{strPtr("134"), 60},
{strPtr("179"), 80},
{strPtr("186"), 186},
{strPtr("417"), 186},
}
for _, tc := range testCases {
result := parseSpeed(&tc.input)
result := parseSpeed(tc.input)
if result != tc.expected {
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
View File

@ -3,7 +3,7 @@ module git.fjla.uk/owlboard/timetable-mgr
go 1.21
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
go.mongodb.org/mongo-driver v1.12.0
go.uber.org/zap v1.24.0

2
go.sum
View File

@ -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-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-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/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=