diff options
author | Christian Pointner <equinox@spreadspace.org> | 2017-04-30 02:45:03 +0200 |
---|---|---|
committer | Christian Pointner <equinox@spreadspace.org> | 2017-04-30 02:45:03 +0200 |
commit | 568c906a342847027d2943ab109d0bbe6a0f02f4 (patch) | |
tree | e5c547b1277df4bda7864ab8b67fad4d1e9c84b5 /src/hub | |
parent | protocol version is not really part of the SourceId (diff) |
fixed last commit
Diffstat (limited to 'src/hub')
-rw-r--r-- | src/hub/src/spreadspace.org/sfive/s5cvt_test.go | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/src/hub/src/spreadspace.org/sfive/s5cvt_test.go b/src/hub/src/spreadspace.org/sfive/s5cvt_test.go index cec0773..9e30b59 100644 --- a/src/hub/src/spreadspace.org/sfive/s5cvt_test.go +++ b/src/hub/src/spreadspace.org/sfive/s5cvt_test.go @@ -39,14 +39,17 @@ import ( ) var ( - sourceIdFields = `"hostname": "localhost", "streamer-id": {"quality": "low", "content-id": "av", "format": "webm"}, "tags": ["elevate", "2014"], "version": 1` - sourceIdData = `{` + sourceIdFields + `}` - sourceIdDataStruct = SourceId{Hostname: "localhost", StreamId: StreamId{Quality: "low", ContentId: "av", Format: "webm"}, Tags: []string{"elevate", "2014"}} - updateFields = `"data": {"bytes-sent": 1, "client-count": 3, "bytes-received": 1}, "start-time": "2014-08-24T14:35:33.847282Z", "duration-ms": 5000` - updateData = "{" + updateFields + "}" - updateDataStruct = DataUpdate{Data: SourceData{BytesSent: 1, ClientCount: 3, BytesReceived: 1}, StartTime: time.Date(2014, time.August, 24, 14, 35, 33, 847282000, time.UTC), Duration: 5000} - testData = "{" + sourceIdFields + "," + updateFields + "}" - statefulInitMessage = `{ "version": 1, ` + sourceIdFields + `}` + sourceIdFields = `"hostname": "localhost", "streamer-id": {"quality": "low", "content-id": "av", "format": "webm"}, "tags": ["elevate", "2014"]` + sourceIdData = `{` + sourceIdFields + `}` + sourceIdDataStruct = SourceId{Hostname: "localhost", StreamId: StreamId{Quality: "low", ContentId: "av", Format: "webm"}, Tags: []string{"elevate", "2014"}} + updateFields = `"data": {"bytes-sent": 1, "client-count": 3, "bytes-received": 1}, "start-time": "2014-08-24T14:35:33.847282Z", "duration-ms": 5000` + updateData = "{" + updateFields + "}" + updateDataStruct = DataUpdate{Data: SourceData{BytesSent: 1, ClientCount: 3, BytesReceived: 1}, StartTime: time.Date(2014, time.August, 24, 14, 35, 33, 847282000, time.UTC), Duration: 5000} + + statefulInitMsg = `{ "version": 1, ` + sourceIdFields + `}` + statefulDataMsg = `{ "version": 1, ` + updateFields + "}" + + statelessDataMsg = `{ "version": 1, ` + sourceIdFields + "," + updateFields + "}" ) func GetExpected() *DataUpdateFull { @@ -58,12 +61,12 @@ func GetExpected() *DataUpdateFull { } func TestDecodeStateful(t *testing.T) { - dc, err := NewStatefulDecoder([]byte(statefulInitMessage)) + dc, err := NewStatefulDecoder([]byte(statefulInitMsg)) if err != nil { t.Errorf("Creating decoder failed with %v", err) return } - dat, err := dc.Decode([]byte(testData)) + dat, err := dc.Decode([]byte(statefulDataMsg)) if err != nil { t.Errorf("Decode failed with %v", err) return @@ -76,7 +79,7 @@ func TestDecodeStateful(t *testing.T) { func TestDecodePlain(t *testing.T) { ec := new(PlainDecoder) - dat, err := ec.Decode([]byte(testData)) + dat, err := ec.Decode([]byte(statelessDataMsg)) if err != nil { t.Errorf("Decode failed with %v", err) return |