| OLD | NEW |
| 1 // Copyright 2015 The LUCI Authors. All rights reserved. | 1 // Copyright 2015 The LUCI Authors. All rights reserved. |
| 2 // Use of this source code is governed under the Apache License, Version 2.0 | 2 // Use of this source code is governed under the Apache License, Version 2.0 |
| 3 // that can be found in the LICENSE file. | 3 // that can be found in the LICENSE file. |
| 4 | 4 |
| 5 package streamserver | 5 package streamserver |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "bytes" | 8 "bytes" |
| 9 "encoding/binary" | 9 "encoding/binary" |
| 10 "fmt" | 10 "fmt" |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 _, err := p.Handshake(ctx, hb.reader("", nil)) | 103 _, err := p.Handshake(ctx, hb.reader("", nil)) |
| 104 So(err, ShouldNotBeNil) | 104 So(err, ShouldNotBeNil) |
| 105 }) | 105 }) |
| 106 | 106 |
| 107 Convey(`Loading an JSON object with just a name`, func() { | 107 Convey(`Loading an JSON object with just a name`, func() { |
| 108 props, err := p.Handshake(ctx, hb.reader(`{"name": "test
"}`, nil)) | 108 props, err := p.Handshake(ctx, hb.reader(`{"name": "test
"}`, nil)) |
| 109 So(err, ShouldBeNil) | 109 So(err, ShouldBeNil) |
| 110 | 110 |
| 111 Convey(`Should produce a valid stream configuration.`, f
unc() { | 111 Convey(`Should produce a valid stream configuration.`, f
unc() { |
| 112 So(props, ShouldResemble, &streamproto.Propertie
s{ | 112 So(props, ShouldResemble, &streamproto.Propertie
s{ |
| 113 » » » » » LogStreamDescriptor: logpb.LogStreamDesc
riptor{ | 113 » » » » » LogStreamDescriptor: &logpb.LogStreamDes
criptor{ |
| 114 Name: "test", | 114 Name: "test", |
| 115 Timestamp: google.NewTimestamp
(tc.Now()), | 115 Timestamp: google.NewTimestamp
(tc.Now()), |
| 116 StreamType: logpb.StreamType_TE
XT, | 116 StreamType: logpb.StreamType_TE
XT, |
| 117 ContentType: string(types.Conten
tTypeText), | 117 ContentType: string(types.Conten
tTypeText), |
| 118 }, | 118 }, |
| 119 }) | 119 }) |
| 120 }) | 120 }) |
| 121 }) | 121 }) |
| 122 | 122 |
| 123 Convey(`Loading a fully-specified configuration`, func() { | 123 Convey(`Loading a fully-specified configuration`, func() { |
| 124 data := `{ | 124 data := `{ |
| 125 "name": "test", "tee": "stdout", "timestamp": "2
015-05-07T01:29:51+00:00", | 125 "name": "test", "tee": "stdout", "timestamp": "2
015-05-07T01:29:51+00:00", |
| 126 "contentType": "text/plain", | 126 "contentType": "text/plain", |
| 127 "tags": {"foo": "bar", "baz": "qux"} | 127 "tags": {"foo": "bar", "baz": "qux"} |
| 128 }` | 128 }` |
| 129 props, err := p.Handshake(ctx, hb.reader(data, nil)) | 129 props, err := p.Handshake(ctx, hb.reader(data, nil)) |
| 130 So(err, ShouldBeNil) | 130 So(err, ShouldBeNil) |
| 131 | 131 |
| 132 Convey(`Should produce a specific configuration.`, func(
) { | 132 Convey(`Should produce a specific configuration.`, func(
) { |
| 133 So(props, ShouldResemble, &streamproto.Propertie
s{ | 133 So(props, ShouldResemble, &streamproto.Propertie
s{ |
| 134 » » » » » LogStreamDescriptor: logpb.LogStreamDesc
riptor{ | 134 » » » » » LogStreamDescriptor: &logpb.LogStreamDes
criptor{ |
| 135 Name: "test", | 135 Name: "test", |
| 136 ContentType: "text/plain", | 136 ContentType: "text/plain", |
| 137 Timestamp: google.NewTimestamp
(time.Date(2015, 05, 07, 1, 29, 51, 0, time.UTC)), | 137 Timestamp: google.NewTimestamp
(time.Date(2015, 05, 07, 1, 29, 51, 0, time.UTC)), |
| 138 Tags: map[string]string{ | 138 Tags: map[string]string{ |
| 139 "baz": "qux", | 139 "baz": "qux", |
| 140 "foo": "bar", | 140 "foo": "bar", |
| 141 }, | 141 }, |
| 142 }, | 142 }, |
| 143 Tee: streamproto.TeeStdout, | 143 Tee: streamproto.TeeStdout, |
| 144 }) | 144 }) |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 func TestHandshakeProtocol(t *testing.T) { | 199 func TestHandshakeProtocol(t *testing.T) { |
| 200 testHandshakeProtocol(t, false) | 200 testHandshakeProtocol(t, false) |
| 201 } | 201 } |
| 202 | 202 |
| 203 // As an optimization, we buffer data differently for verbose output. This | 203 // As an optimization, we buffer data differently for verbose output. This |
| 204 // creates a separate code path that we have to take if logging verbose function | 204 // creates a separate code path that we have to take if logging verbose function |
| 205 // is set. | 205 // is set. |
| 206 func TestHandshakeProtocolVerbose(t *testing.T) { | 206 func TestHandshakeProtocolVerbose(t *testing.T) { |
| 207 testHandshakeProtocol(t, true) | 207 testHandshakeProtocol(t, true) |
| 208 } | 208 } |
| OLD | NEW |