Skip to content

Commit

Permalink
Merge pull request #1119 from openshift-kni/buildinfo-tests
Browse files Browse the repository at this point in the history
internal: buildinfo: add missing test coverage
  • Loading branch information
ffromani authored Dec 16, 2024
2 parents 0aa74e8 + bef3202 commit 63a9be6
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions internal/api/buildinfo/types_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Copyright 2024 Red Hat, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package buildinfo

import "testing"

func TestString(t *testing.T) {
type testCase struct {
name string
binfo BuildInfo
expected string
}

testCases := []testCase{
{
name: "empty",
expected: " ()",
},
{
name: "random dummy values",
binfo: BuildInfo{
Branch: "main",
Version: "1.0",
Commit: "c0ffee42",
},
expected: "1.0 c0ffee42 (main)",
},
}

for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
got := tc.binfo.String()
if got != tc.expected {
t.Errorf("got=%q expected=%q", got, tc.expected)
}
})
}
}

0 comments on commit 63a9be6

Please sign in to comment.