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

Side by Side Diff: client/flagpb/unmarshal_test.go

Issue 1940683002: client/flagpb: fix unmarshaling of maps (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-go@flagpb-parse-value
Patch Set: -mapcase Created 4 years, 7 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 flagpb 5 package flagpb
6 6
7 import ( 7 import (
8 "io/ioutil" 8 "io/ioutil"
9 "testing" 9 "testing"
10 10
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 Convey("string and int32", func() { 165 Convey("string and int32", func() {
166 So(unmarshalOK("M1", "-s", "x", "-i", "1"), ShouldResemb le, msg( 166 So(unmarshalOK("M1", "-s", "x", "-i", "1"), ShouldResemb le, msg(
167 "s", "x", 167 "s", "x",
168 "i", int32(1), 168 "i", int32(1),
169 )) 169 ))
170 }) 170 })
171 171
172 Convey("repeated", func() { 172 Convey("repeated", func() {
173 Convey("int32", func() { 173 Convey("int32", func() {
174 So(unmarshalOK("M1", "-ri", "1", "-ri", "2"), Sh ouldResemble, msg( 174 So(unmarshalOK("M1", "-ri", "1", "-ri", "2"), Sh ouldResemble, msg(
175 » » » » » "ri", []interface{}{int32(1), int32(2)}, 175 » » » » » "ri", repeated(int32(1), int32(2)),
176 )) 176 ))
177 }) 177 })
178 Convey("submessage string", func() { 178 Convey("submessage string", func() {
179 Convey("works", func() { 179 Convey("works", func() {
180 So(unmarshalOK("M3", "-m1.s", "x", "-m1" , "-m1.s", "y"), ShouldResemble, msg( 180 So(unmarshalOK("M3", "-m1.s", "x", "-m1" , "-m1.s", "y"), ShouldResemble, msg(
181 » » » » » » "m1", []interface{}{ 181 » » » » » » "m1", repeated(
182 msg("s", "x"), 182 msg("s", "x"),
183 msg("s", "y"), 183 msg("s", "y"),
184 » » » » » » }, 184 » » » » » » ),
185 )) 185 ))
186 }) 186 })
187 Convey("reports meaningful error", func() { 187 Convey("reports meaningful error", func() {
188 err := unmarshalErr("M3", "-m1.s", "x", "-m1.s", "y") 188 err := unmarshalErr("M3", "-m1.s", "x", "-m1.s", "y")
189 So(err, ShouldErrLike, `-m1.s: value is already set`) 189 So(err, ShouldErrLike, `-m1.s: value is already set`)
190 So(err, ShouldErrLike, `insert -m1`) 190 So(err, ShouldErrLike, `insert -m1`)
191 }) 191 })
192 }) 192 })
193 }) 193 })
194
195 Convey("map", func() {
196 Convey("map<string, string>", func() {
197 So(unmarshalOK("MapContainer", "-ss.x", "a", "-s s.y", "b"), ShouldResemble, msg(
198 "ss", msg("x", "a", "y", "b"),
199 ))
200 })
201 Convey("map<int32, int32>", func() {
202 So(unmarshalOK("MapContainer", "-ii.1", "10", "- ii.2", "20"), ShouldResemble, msg(
203 "ii", msg("1", int32(10), "2", int32(20) ),
204 ))
205 })
206 Convey("map<string, M1>", func() {
207 So(unmarshalOK("MapContainer", "-sm1.x.s", "a", "-sm1.y.s", "b"), ShouldResemble, msg(
208 "sm1", msg(
209 "x", msg("s", "a"),
210 "y", msg("s", "b"),
211 ),
212 ))
213 })
214 })
194 }) 215 })
195 } 216 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698