From b0869424388d3fb3c72542fb845b87a0ba407c5c Mon Sep 17 00:00:00 2001 From: AtomicFS Date: Mon, 20 Jan 2025 14:59:40 +0100 Subject: [PATCH] chore(cmd): unify assert parameters - fix order of parameters to match expected and actual Signed-off-by: AtomicFS --- cmd/firmware-action/filesystem/filesystem_test.go | 4 ++-- cmd/firmware-action/filesystem/git_test.go | 4 ++-- cmd/firmware-action/recipes/linux_test.go | 6 ++++-- cmd/firmware-action/recipes/recipes_test.go | 4 ++-- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/cmd/firmware-action/filesystem/filesystem_test.go b/cmd/firmware-action/filesystem/filesystem_test.go index b8bf4553..c6a56372 100644 --- a/cmd/firmware-action/filesystem/filesystem_test.go +++ b/cmd/firmware-action/filesystem/filesystem_test.go @@ -110,7 +110,7 @@ func TestLastSaveRunTime(t *testing.T) { // Load - should fallback because no file exists, but no error loadTime, err := LoadLastRunTime(pathTimeFile) assert.NoError(t, err) - assert.Equal(t, loadTime, time.Time{}) + assert.Equal(t, time.Time{}, loadTime) assert.ErrorIs(t, CheckFileExists(pathTimeFile), os.ErrNotExist) // Save @@ -133,7 +133,7 @@ func TestGetFileModTime(t *testing.T) { // Missing file - should fail modTime, err := GetFileModTime(pathFile) assert.ErrorIs(t, err, os.ErrNotExist) - assert.Equal(t, modTime, time.Time{}) + assert.Equal(t, time.Time{}, modTime) assert.ErrorIs(t, CheckFileExists(pathFile), os.ErrNotExist) // Make file diff --git a/cmd/firmware-action/filesystem/git_test.go b/cmd/firmware-action/filesystem/git_test.go index 6708b82d..57b57b32 100644 --- a/cmd/firmware-action/filesystem/git_test.go +++ b/cmd/firmware-action/filesystem/git_test.go @@ -56,7 +56,7 @@ func TestGitRun(t *testing.T) { // Test git status stdout, err := gitRun("./", []string{"git", "status"}) assert.NoError(t, err) - assert.Equal(t, stdout, "On branch master\nnothing to commit, working tree clean\n") + assert.Equal(t, "On branch master\nnothing to commit, working tree clean\n", stdout) } func TestGitDescribeCoreboot(t *testing.T) { @@ -73,7 +73,7 @@ func TestGitDescribeCoreboot(t *testing.T) { // Test git status describe, err := GitDescribeCoreboot("./") assert.NoError(t, err) - assert.Equal(t, describe, "4eeb1eaf0c81") + assert.Equal(t, "4eeb1eaf0c81", describe) // This magic value comes from manual execution of the test // Since the content, author and time of the commit are hard-coded, // the commit hash is always the same diff --git a/cmd/firmware-action/recipes/linux_test.go b/cmd/firmware-action/recipes/linux_test.go index 57341432..01e1700c 100644 --- a/cmd/firmware-action/recipes/linux_test.go +++ b/cmd/firmware-action/recipes/linux_test.go @@ -155,8 +155,10 @@ func TestLinux(t *testing.T) { assert.ErrorIs(t, err, tc.wantErr) // Check artifacts - assert.ErrorIs(t, filesystem.CheckFileExists(filepath.Join(outputPath, "vmlinux")), os.ErrExist) - assert.ErrorIs(t, filesystem.CheckFileExists(filepath.Join(outputPath, "defconfig")), os.ErrExist) + if tc.wantErr == nil { + assert.ErrorIs(t, filesystem.CheckFileExists(filepath.Join(outputPath, "vmlinux")), os.ErrExist) + assert.ErrorIs(t, filesystem.CheckFileExists(filepath.Join(outputPath, "defconfig")), os.ErrExist) + } }) } assert.NoError(t, os.Chdir(pwd)) // just to make sure diff --git a/cmd/firmware-action/recipes/recipes_test.go b/cmd/firmware-action/recipes/recipes_test.go index be17b760..e0b0613e 100644 --- a/cmd/firmware-action/recipes/recipes_test.go +++ b/cmd/firmware-action/recipes/recipes_test.go @@ -225,7 +225,7 @@ func TestBuild(t *testing.T) { "edk2-build-b": {Depends: []string{}}, }, FirmwareStitching: map[string]FirmwareStitchingOpts{ - "stitch": {Depends: []string{"edk2-build-a"}}, + "stitch": {Depends: []string{"edk2-build-a"}}, }, }, }, @@ -239,7 +239,7 @@ func TestBuild(t *testing.T) { "edk2-build": {Depends: []string{}}, }, FirmwareStitching: map[string]FirmwareStitchingOpts{ - "stitch-a": {Depends: []string{"edk2-build"}}, + "stitch-a": {Depends: []string{"edk2-build"}}, "stitch-b": {Depends: []string{"edk2-build"}}, }, },