go.chromium.org/luci@v0.0.0-20240309015107-7cdc2e660f33/common/git/footer/tag_test.go (about) 1 // Copyright 2020 The LUCI Authors. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package footer 16 17 import ( 18 "testing" 19 20 "go.chromium.org/luci/common/data/strpair" 21 22 . "github.com/smartystreets/goconvey/convey" 23 ) 24 25 func TestParseLegacyMetadata(t *testing.T) { 26 t.Parallel() 27 28 Convey("ParseLegacyMetadata", t, func() { 29 Convey("Complete", func() { 30 actual := ParseLegacyMetadata(`message 31 32 commit details... 33 MD_ONE=1111 34 more details... 35 36 MD-HYPHEN=invalid 37 MD_lowercase=invalid 38 Footer: Cool 39 MD_TWO=2222 40 Footer: Awesome 41 `) 42 So(actual, ShouldResemble, strpair.ParseMap([]string{ 43 "MD_ONE:1111", 44 "MD_TWO:2222", 45 })) 46 }) 47 Convey("Honor metadata order", func() { 48 actual := ParseLegacyMetadata(`MD_FOO=foo 49 MD_FOO=bar 50 MD_FOO=baz 51 `) 52 So(actual["MD_FOO"], ShouldResemble, []string{ 53 "baz", 54 "bar", 55 "foo", 56 }) 57 }) 58 }) 59 }