sigs.k8s.io/prow@v0.0.0-20240503223140-c5e374dc7eb1/pkg/bugzilla/status_test.go (about) 1 /* 2 Copyright 2019 The Kubernetes Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package bugzilla 18 19 import "testing" 20 21 func TestPrettyStatus(t *testing.T) { 22 testCases := []struct { 23 name string 24 status string 25 resolution string 26 expected string 27 }{ 28 { 29 name: "both empty", 30 expected: "", 31 }, 32 { 33 name: "only status", 34 status: "CLOSED", 35 expected: "CLOSED", 36 }, 37 { 38 name: "only resolution", 39 resolution: "NOTABUG", 40 expected: "any status with resolution NOTABUG", 41 }, 42 { 43 name: "status and resolution", 44 status: "CLOSED", 45 resolution: "NOTABUG", 46 expected: "CLOSED (NOTABUG)", 47 }, 48 } 49 for _, tc := range testCases { 50 t.Run(tc.name, func(t *testing.T) { 51 actual := PrettyStatus(tc.status, tc.resolution) 52 if actual != tc.expected { 53 t.Errorf("%s: expected %q, got %q", tc.name, tc.expected, actual) 54 } 55 }) 56 } 57 }