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

Side by Side Diff: common/logging/fields_test.go

Issue 1622553005: Remove log filtering and add stringsetflag. (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-go@master
Patch Set: error on empty Created 4 years, 11 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 | « common/logging/fields.go ('k') | common/logging/filter.go » ('j') | 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 Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package logging 5 package logging
6 6
7 import ( 7 import (
8 "errors" 8 "errors"
9 "fmt" 9 "fmt"
10 "sort" 10 "sort"
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 So(fm, ShouldHaveSameTypeAs, Fields(nil)) 121 So(fm, ShouldHaveSameTypeAs, Fields(nil))
122 122
123 Convey(`Returns an augmented Fields when Copied with a populated Fields.`, func() { 123 Convey(`Returns an augmented Fields when Copied with a populated Fields.`, func() {
124 other := Fields{ 124 other := Fields{
125 ErrorKey: errors.New("err"), 125 ErrorKey: errors.New("err"),
126 } 126 }
127 So(fm.Copy(other), ShouldResemble, Fields{"foo": "bar", "baz": "qux", ErrorKey: errors.New("err")}) 127 So(fm.Copy(other), ShouldResemble, Fields{"foo": "bar", "baz": "qux", ErrorKey: errors.New("err")})
128 }) 128 })
129 129
130 Convey(`Has a String representation: {"baz":"qux", "foo":"bar"}` , func() { 130 Convey(`Has a String representation: {"baz":"qux", "foo":"bar"}` , func() {
131 » » » So(fm.FieldString(false), ShouldEqual, `{"baz":"qux", "f oo":"bar"}`) 131 » » » So(fm.String(), ShouldEqual, `{"baz":"qux", "foo":"bar"} `)
132 » » })
133
134 » » Convey(`With a FilterOn key`, func() {
135 » » » fm = fm.Copy(Fields{
136 » » » » FilterOnKey: "test",
137 » » » })
138
139 » » » Convey(`Has a pruned String representation: {"baz":"qux" , "foo":"bar"}`, func() {
140 » » » » So(fm.FieldString(true), ShouldEqual, `{"baz":"q ux", "foo":"bar"}`)
141 » » » })
142 }) 132 })
143 }) 133 })
144 } 134 }
145 135
146 func TestContextFields(t *testing.T) { 136 func TestContextFields(t *testing.T) {
147 Convey(`An empty Context`, t, func() { 137 Convey(`An empty Context`, t, func() {
148 c := context.Background() 138 c := context.Background()
149 139
150 Convey(`Has no Fields.`, func() { 140 Convey(`Has no Fields.`, func() {
151 So(GetFields(c), ShouldBeNil) 141 So(GetFields(c), ShouldBeNil)
(...skipping 17 matching lines...) Expand all
169 159
170 So(GetFields(c), ShouldResemble, Fields{ 160 So(GetFields(c), ShouldResemble, Fields{
171 "foo": "override", 161 "foo": "override",
172 "baz": "qux", 162 "baz": "qux",
173 "error": errors.New("failure"), 163 "error": errors.New("failure"),
174 }) 164 })
175 }) 165 })
176 }) 166 })
177 }) 167 })
178 } 168 }
OLDNEW
« no previous file with comments | « common/logging/fields.go ('k') | common/logging/filter.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698