Skip to content

Commit

Permalink
chore(cmd): fixup logging in tests
Browse files Browse the repository at this point in the history
- replace log.Print() and fmt.Print() with t.Log()

Signed-off-by: AtomicFS <[email protected]>
  • Loading branch information
AtomicFS committed Jan 29, 2025
1 parent f1f0b73 commit 5b573b8
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
3 changes: 1 addition & 2 deletions cmd/firmware-action/environment/environment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
package environment

import (
"fmt"
"os"
"testing"

Expand Down Expand Up @@ -51,7 +50,7 @@ func TestValidateConfig(t *testing.T) {
for key, value := range tc.envCreate {
os.Setenv(key, value)
defer os.Unsetenv(key)
fmt.Printf("Setting %s = %s\n", key, value)
t.Logf("Setting %s = %s\n", key, value)
}

result := FetchEnvVars(tc.envSearchFor)
Expand Down
9 changes: 4 additions & 5 deletions cmd/firmware-action/recipes/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
package recipes

import (
"fmt"
"os"
"path/filepath"
"reflect"
Expand Down Expand Up @@ -116,7 +115,7 @@ func TestConfigReadAndWrite(t *testing.T) {
// Compare
equal := cmp.Equal(&configOriginal, configNew)
if !equal {
fmt.Println(cmp.Diff(configOriginal, configNew))
t.Log(cmp.Diff(configOriginal, configNew))
assert.True(t, equal, "written and read configuration are not equal")
}
}
Expand Down Expand Up @@ -156,8 +155,8 @@ func TestFindAllEnvVars(t *testing.T) {
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
foundVars := FindAllEnvVars(tc.text)
fmt.Println(foundVars)
fmt.Println(tc.expectedEnvVars)
t.Log(foundVars)
t.Log(tc.expectedEnvVars)

assert.Equal(t, len(tc.expectedEnvVars), len(foundVars))
// If both slices are of zero length, then the comparison fails for whatever reason
Expand Down Expand Up @@ -258,7 +257,7 @@ func TestConfigEnvVars(t *testing.T) {
for key, value := range tc.envVars {
os.Setenv(key, value)
defer os.Unsetenv(key)
fmt.Printf("Setting %s = %s\n", key, value)
t.Logf("Setting %s = %s\n", key, value)
}

// Write and read config
Expand Down
4 changes: 2 additions & 2 deletions cmd/firmware-action/recipes/coreboot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func TestCorebootProcessBlobs(t *testing.T) {

equal := cmp.Equal(tc.expected, output)
if !equal {
fmt.Println(cmp.Diff(tc.expected, output))
t.Log(cmp.Diff(tc.expected, output))
assert.True(t, equal, "processing blob parameters failed")
}
})
Expand Down Expand Up @@ -583,7 +583,7 @@ func TestCorebootSubmodule(t *testing.T) {
for key, value := range tc.envVars {
os.Setenv(key, value)
defer os.Unsetenv(key)
fmt.Printf("Setting %s = %s\n", key, value)
t.Logf("Setting %s = %s\n", key, value)
}

// Make version file if required
Expand Down
4 changes: 2 additions & 2 deletions cmd/firmware-action/recipes/stitching_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func TestExtractSizeFromString(t *testing.T) {
result, err := ExtractSizeFromString(tc.stdout)
equal := cmp.Equal(tc.expected, result)
if !equal {
fmt.Println(cmp.Diff(tc.expected, result))
t.Log(cmp.Diff(tc.expected, result))
assert.True(t, equal, "failed to extract size of ROM from string")
}
assert.ErrorIs(t, err, tc.wantErr)
Expand Down Expand Up @@ -126,7 +126,7 @@ func TestStringToSizeMB(t *testing.T) {
result, err := StringToSizeMB(tc.text)
equal := cmp.Equal(tc.expected, result)
if !equal {
fmt.Println(cmp.Diff(tc.expected, result))
t.Log(cmp.Diff(tc.expected, result))
assert.True(t, equal, "failed to decipher size")
}
assert.ErrorIs(t, err, tc.wantErr)
Expand Down

0 comments on commit 5b573b8

Please sign in to comment.