Added direction notes

This commit is contained in:
2022-09-17 06:42:49 +08:00
parent 7fd8d4fb6a
commit b251e35be4
5 changed files with 44 additions and 4 deletions

View File

@@ -1,6 +1,7 @@
package kmb
import (
"fmt"
"strings"
query "github.com/tgckpg/golifehk/query"
@@ -36,11 +37,21 @@ func ( this *QueryResult ) Message() ( string, error ) {
sb.WriteString( "\n " )
for _, route := range *b.Routes {
utils.WriteMDv2Text( &sb, route.RouteId )
if route.Direction == "O" {
sb.WriteString( "↑" )
} else if route.Direction == "I" {
sb.WriteString( "↓" )
}
if route.ServiceType != "1" {
utils.WriteMDv2Text( &sb, utils.ToPower( route.ServiceType ) )
}
sb.WriteString( " " )
}
sb.WriteString( "\n" )
}
}
fmt.Print( this.Query.Key )
} else {
}
return sb.String(), nil

View File

@@ -6,5 +6,16 @@ import (
)
func TestQuerySchedule( t *testing.T ) {
fmt.Print( Query( "zh", "大欖" ).Message() )
qo := Query( "zh-Hant", "68X" )
mesg, err := qo.Message()
if err != nil {
t.Errorf( "Unexpected Error: %s", err )
}
fmt.Println( mesg )
qo = Query( "zh-Hant", "K66 朗屏" )
mesg, err = qo.Message()
if err == nil {
t.Errorf( "Expected Error: %s, got \"\" instead", mesg )
}
}