36 line
745 B
Go
36 line
745 B
Go
package liquidsoap
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
type lineParseTest struct {
|
|
Line string
|
|
Err error
|
|
Out Output
|
|
}
|
|
|
|
var lines = []lineParseTest{
|
|
{"2014/10/13 02:58:16 [/foo(dot)mp3:2] Connection failed: 401",
|
|
nil, Output{Level: 2, Msg: "Connection failed: 401", Component: "/foo(dot)mp3"}},
|
|
{"2014/10/13 02:58:16 [asd:1] Gulp[every,strange,char!]",
|
|
nil, Output{Level: 1, Msg: "Gulp[every,strange,char!]", Component: "asd"}},
|
|
}
|
|
|
|
func TestLine(t *testing.T) {
|
|
for _, pair := range lines {
|
|
out, err := outParseLine(pair.Line)
|
|
if err != pair.Err {
|
|
t.Error(
|
|
"For", pair.Line,
|
|
"error expected", pair.Err,
|
|
"got", err)
|
|
}
|
|
if out != pair.Out {
|
|
t.Error(
|
|
"For", pair.Line,
|
|
"expected", pair.Out,
|
|
"got", out)
|
|
}
|
|
}
|
|
}
|