golifehk/datasources/mtr/bus/query_test.go

34 lines
686 B
Go

package bus
import (
"fmt"
"strings"
"testing"
)
func TestQuery( t *testing.T ) {
qo := Query( "zh-Hant", "K73" )
mesg, err := qo.Message()
if err != nil {
t.Errorf( "Unexpected Error: %s", err )
}
if !strings.Contains( mesg, "K73\\-O" ) {
t.Errorf( "Expected Route Listing, got \"%s\" instead", mesg )
}
qo = Query( "zh-Hant", "K76 池" )
mesg, err = qo.Message()
if err == nil {
t.Errorf( "Expecting error, got \"%s\" instead", mesg )
}
qo = Query( "zh-Hant", "K73 池" )
mesg, err = qo.Message()
if err != nil {
t.Errorf( "Unexpected Error: %s", err )
}
fmt.Println( mesg )
}