Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(600)

Side by Side Diff: logdog/common/types/streamname_test.go

Issue 2699943004: LogDog: Implement StreamName.Split. (Closed)
Patch Set: comments Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « logdog/common/types/streamname.go ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 types 5 package types
6 6
7 import ( 7 import (
8 "flag" 8 "flag"
9 "fmt" 9 "fmt"
10 "strings" 10 "strings"
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 {StreamName("foo/bar"), []string{"foo", "bar"}, 2}, 155 {StreamName("foo/bar"), []string{"foo", "bar"}, 2},
156 {StreamName("foo/bar/baz"), []string{"foo", "bar", "baz" }, 3}, 156 {StreamName("foo/bar/baz"), []string{"foo", "bar", "baz" }, 3},
157 } { 157 } {
158 Convey(fmt.Sprintf(`Stream Name "%s" has %d segments: %v `, entry.s, entry.n, entry.p), func() { 158 Convey(fmt.Sprintf(`Stream Name "%s" has %d segments: %v `, entry.s, entry.n, entry.p), func() {
159 So(entry.s.Segments(), ShouldResemble, entry.p) 159 So(entry.s.Segments(), ShouldResemble, entry.p)
160 So(len(entry.s.Segments()), ShouldEqual, entry.s .SegmentCount()) 160 So(len(entry.s.Segments()), ShouldEqual, entry.s .SegmentCount())
161 So(len(entry.s.Segments()), ShouldEqual, entry.n ) 161 So(len(entry.s.Segments()), ShouldEqual, entry.n )
162 }) 162 })
163 } 163 }
164 }) 164 })
165
166 Convey(`StreamName.Split`, t, func() {
167 for _, tc := range []struct {
168 s StreamName
169 base StreamName
170 last StreamName
171 }{
172 {"", "", ""},
173 {"foo", "", "foo"},
174 {"/foo", "", "foo"},
175 {"foo/bar", "foo", "bar"},
176 {"foo/bar/baz", "foo/bar", "baz"},
177 } {
178 Convey(fmt.Sprintf(`Stream name %q splits into %q and %q .`, tc.s, tc.base, tc.last), func() {
179 base, last := tc.s.Split()
180 So(base, ShouldEqual, tc.base)
181 So(last, ShouldEqual, tc.last)
182 })
183 }
184 })
165 } 185 }
166 186
167 func TestStreamPath(t *testing.T) { 187 func TestStreamPath(t *testing.T) {
168 t.Parallel() 188 t.Parallel()
169 189
170 Convey(`StreamPath.Split, StreamPath.Validate`, t, func() { 190 Convey(`StreamPath.Split, StreamPath.Validate`, t, func() {
171 type e struct { 191 type e struct {
172 p string // The stream path. 192 p string // The stream path.
173 prefix string // The split prefix. 193 prefix string // The split prefix.
174 name string // The split name. 194 name string // The split name.
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 248
229 if p == "" { 249 if p == "" {
230 break 250 break
231 } 251 }
232 } 252 }
233 So(parts, ShouldResemble, tc.c) 253 So(parts, ShouldResemble, tc.c)
234 }) 254 })
235 } 255 }
236 }) 256 })
237 } 257 }
OLDNEW
« no previous file with comments | « logdog/common/types/streamname.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698