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

Unified 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, 8 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 side-by-side diff with in-line comments
Download patch
Index: client/flagpb/unmarshal_test.go
diff --git a/client/flagpb/unmarshal_test.go b/client/flagpb/unmarshal_test.go
index 790290303c38cb16dd9d1557164147c87008fb3f..7064c651fc0921766c41bb8b8eb7c13027815929 100644
--- a/client/flagpb/unmarshal_test.go
+++ b/client/flagpb/unmarshal_test.go
@@ -172,16 +172,16 @@ func TestUnmarshal(t *testing.T) {
Convey("repeated", func() {
Convey("int32", func() {
So(unmarshalOK("M1", "-ri", "1", "-ri", "2"), ShouldResemble, msg(
- "ri", []interface{}{int32(1), int32(2)},
+ "ri", repeated(int32(1), int32(2)),
))
})
Convey("submessage string", func() {
Convey("works", func() {
So(unmarshalOK("M3", "-m1.s", "x", "-m1", "-m1.s", "y"), ShouldResemble, msg(
- "m1", []interface{}{
+ "m1", repeated(
msg("s", "x"),
msg("s", "y"),
- },
+ ),
))
})
Convey("reports meaningful error", func() {
@@ -191,5 +191,26 @@ func TestUnmarshal(t *testing.T) {
})
})
})
+
+ Convey("map", func() {
+ Convey("map<string, string>", func() {
+ So(unmarshalOK("MapContainer", "-ss.x", "a", "-ss.y", "b"), ShouldResemble, msg(
+ "ss", msg("x", "a", "y", "b"),
+ ))
+ })
+ Convey("map<int32, int32>", func() {
+ So(unmarshalOK("MapContainer", "-ii.1", "10", "-ii.2", "20"), ShouldResemble, msg(
+ "ii", msg("1", int32(10), "2", int32(20)),
+ ))
+ })
+ Convey("map<string, M1>", func() {
+ So(unmarshalOK("MapContainer", "-sm1.x.s", "a", "-sm1.y.s", "b"), ShouldResemble, msg(
+ "sm1", msg(
+ "x", msg("s", "a"),
+ "y", msg("s", "b"),
+ ),
+ ))
+ })
+ })
})
}

Powered by Google App Engine
This is Rietveld 408576698