-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Cailyn Edwards
committed
Jan 25, 2023
1 parent
da5d572
commit e36ea7c
Showing
8 changed files
with
167 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package provenance_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"sigs.k8s.io/kustomize/api/provenance" | ||
) | ||
|
||
func TestGetProvenance(t *testing.T) { | ||
p := provenance.GetProvenance() | ||
// These are not set during go test: https://github.com/golang/go/issues/33976 | ||
assert.Equal(t, "unknown", p.Version) | ||
assert.Equal(t, "unknown", p.BuildDate) | ||
assert.Equal(t, "unknown", p.GitCommit) | ||
|
||
// These are set properly during go test | ||
assert.NotEmpty(t, p.GoArch) | ||
assert.NotEmpty(t, p.GoOs) | ||
assert.Contains(t, p.GoVersion, "go1.") | ||
} | ||
|
||
func TestProvenance_Short(t *testing.T) { | ||
p := provenance.GetProvenance() | ||
// The version not set during go test, so this comes from an ldflag: https://github.com/golang/go/issues/33976 | ||
assert.Equal(t, "unknown", p.Short()) | ||
|
||
p.Version = "kustomize/v4.11.12" | ||
assert.Equal(t, "v4.11.12", p.Short()) | ||
} | ||
|
||
func TestProvenance_Full(t *testing.T) { | ||
p := provenance.GetProvenance() | ||
// Most values are not set during go test: https://github.com/golang/go/issues/33976 | ||
assert.Contains(t, p.Full(), "{Version:unknown GitCommit:unknown BuildDate:unknown") | ||
assert.Regexp(t, "GoOs:\\w+ GoArch:\\w+ GoVersion:go1", p.Full()) | ||
} | ||
|
||
func TestProvenance_Semver(t *testing.T) { | ||
p := provenance.GetProvenance() | ||
// The version not set during go test | ||
assert.Equal(t, "unknown", p.Semver()) | ||
|
||
p.Version = "kustomize/v4.11.12" | ||
assert.Equal(t, "v4.11.12", p.Semver()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters