52 lines
1.2 KiB
Go
52 lines
1.2 KiB
Go
package streams
|
||
|
||
import (
|
||
"fmt"
|
||
"testing"
|
||
|
||
. "github.com/smartystreets/goconvey/convey"
|
||
)
|
||
|
||
const (
|
||
originalStringA = "Aäöü´ß - \\_-_-_"
|
||
quotedStringA = "'Aäöü´ß - \\\\_-_-_'"
|
||
originalStringB = "hfn9'07';137gr\tbqp9\"ui"
|
||
quotedStringB = "'hfn9\\'07\\';137gr\tbqp9\"ui'"
|
||
)
|
||
|
||
func Test_Metadata(t *testing.T) {
|
||
Convey("Metadata", t, func() {
|
||
Convey("decoding", func() {
|
||
meta, err := DecodeMetadata("")
|
||
So(err, ShouldBeNil)
|
||
So(meta, ShouldHaveLength, 0)
|
||
|
||
meta, err = DecodeMetadata("StreamTitle=" + quotedStringA + ";")
|
||
So(err, ShouldBeNil)
|
||
So(meta, ShouldHaveLength, 1)
|
||
So(meta, ShouldContainKey, "StreamTitle")
|
||
So(meta["StreamTitle"], ShouldEqual, originalStringA)
|
||
})
|
||
|
||
Convey("encoding", func() {
|
||
meta := Metadata{}
|
||
So(meta.String(), ShouldHaveLength, 0)
|
||
|
||
meta = Metadata{
|
||
"StreamTitle": originalStringA,
|
||
}
|
||
So(meta.String(), ShouldEqual,
|
||
fmt.Sprintf("StreamTitle=%s;",
|
||
quotedStringA))
|
||
|
||
meta = Metadata{
|
||
"StreamTitle": originalStringA,
|
||
"test": originalStringB,
|
||
}
|
||
So(meta.String(), ShouldEqual,
|
||
fmt.Sprintf("StreamTitle=%s;test=%s;",
|
||
quotedStringA, quotedStringB))
|
||
})
|
||
})
|
||
}
|