diff options
| author | Mangaal <44372157+Mangaal@users.noreply.github.com> | 2024-07-11 17:40:20 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-11 08:10:20 -0400 |
| commit | a65410b5e1f768339bdb39a9287134f22ffaa7a9 (patch) | |
| tree | 9f95ae5c60f8c738357cad2734ccb7eda7ed91f2 /pkg/version | |
| parent | 80d2731d1335e7ae860cd810f7403f43379f7998 (diff) | |
chore(tests): Add unit tests to image-updater pkg/health, pkg/version and pkg/registry (#771)
Signed-off-by: Mangaal <angommeeteimangaal@gmail.com>
Diffstat (limited to 'pkg/version')
| -rw-r--r-- | pkg/version/version_test.go | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/pkg/version/version_test.go b/pkg/version/version_test.go index 638daa4..a3d9db7 100644 --- a/pkg/version/version_test.go +++ b/pkg/version/version_test.go @@ -1,6 +1,7 @@ package version import ( + "runtime" "testing" "github.com/stretchr/testify/assert" @@ -18,3 +19,33 @@ func Test_Version(t *testing.T) { func Test_Useragent(t *testing.T) { assert.Regexp(t, `^[a-z\-]+:\sv[0-9]+\.[0-9]+\.[0-9]+(-[a-z]+)*(\+[a-z0-9]+)*$`, Useragent()) } + +func TestGitCommit(t *testing.T) { + expected := "unknown" + actual := GitCommit() + assert.Equal(t, expected, actual, "GitCommit should return the correct git commit hash") +} + +func TestBuildDate(t *testing.T) { + expected := "1970-01-01T00:00:00Z" + actual := BuildDate() + assert.Equal(t, expected, actual, "BuildDate should return the correct build date") +} + +func TestGoVersion(t *testing.T) { + expected := runtime.Version() + actual := GoVersion() + assert.Equal(t, expected, actual, "GoVersion should return the correct Go version") +} + +func TestGoPlatform(t *testing.T) { + expected := runtime.GOOS + "/" + runtime.GOARCH + actual := GoPlatform() + assert.Equal(t, expected, actual, "GoPlatform should return the correct Go platform") +} + +func TestGoCompiler(t *testing.T) { + expected := runtime.Compiler + actual := GoCompiler() + assert.Equal(t, expected, actual, "GoCompiler should return the correct Go compiler") +} |
