| Index: logdog/common/types/streamaddr_test.go
|
| diff --git a/logdog/common/types/streamaddr_test.go b/logdog/common/types/streamaddr_test.go
|
| index 1f8a9b2dec21fa07b06d281397ccd70d8db64cd7..347645562bad2af07ad381d582d092e03286c5c6 100644
|
| --- a/logdog/common/types/streamaddr_test.go
|
| +++ b/logdog/common/types/streamaddr_test.go
|
| @@ -5,6 +5,7 @@
|
| package types
|
|
|
| import (
|
| + "encoding/json"
|
| "flag"
|
| "fmt"
|
| "net/url"
|
| @@ -79,4 +80,36 @@ func TestStreamAddr(t *testing.T) {
|
| "failed to parse URL")
|
| })
|
| })
|
| +
|
| + Convey(`StreamAddr as a json value`, t, func() {
|
| + a := &StreamAddr{}
|
| +
|
| + Convey(`good`, func() {
|
| + Convey(`zero`, func() {
|
| + data, err := json.Marshal(a)
|
| + So(err, ShouldBeNil)
|
| + So(string(data), ShouldResemble, `{}`)
|
| + So(json.Unmarshal(data, a), ShouldBeNil)
|
| + So(a, ShouldResemble, &StreamAddr{})
|
| + })
|
| +
|
| + Convey(`full`, func() {
|
| + a.Host = "host"
|
| + a.Project = "project"
|
| + a.Path = "a/+/b"
|
| + data, err := json.Marshal(a)
|
| + So(err, ShouldBeNil)
|
| + So(string(data), ShouldResemble, `{"host":"host","project":"project","path":"a/+/b"}`)
|
| +
|
| + a2 := &StreamAddr{}
|
| + So(json.Unmarshal(data, a2), ShouldBeNil)
|
| + So(a2, ShouldResemble, a)
|
| + })
|
| + })
|
| +
|
| + Convey(`bad`, func() {
|
| + So(json.Unmarshal([]byte(`{"host":"host","project":"project","path":"fake"}`), a), ShouldErrLike,
|
| + "must contain at least one character") // from bad Path
|
| + })
|
| + })
|
| }
|
|
|