go.fuchsia.dev/infra@v0.0.0-20240507153436-9b593402251b/cmd/autogardener/commit_tag_test.go (about) 1 // Copyright 2022 The Fuchsia Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 package main 6 7 import ( 8 "testing" 9 ) 10 11 func TestHasMatchingTag(t *testing.T) { 12 commitMsg := "[foo][bar] Do something\n\nBody\nBody\n\nFooter: val" 13 t.Run("no matching tag", func(t *testing.T) { 14 m := hasMatchingTag(commitMsg, "non-matching-test") 15 if m { 16 t.Errorf("Expected no matching tag, but got a match") 17 } 18 }) 19 20 t.Run("matching tag", func(t *testing.T) { 21 m := hasMatchingTag(commitMsg, "matching-foo-test") 22 if !m { 23 t.Errorf("Expected matching tag, but got no match") 24 } 25 }) 26 27 t.Run("ignores separators", func(t *testing.T) { 28 commitMsg := "[foo-bar] Do something" 29 m := hasMatchingTag(commitMsg, "integration_foo_bar_test") 30 if !m { 31 t.Errorf("Expected matching tag, but got no match") 32 } 33 }) 34 }