more lint errors

This commit is contained in:
Christopher Homberger
2026-02-23 00:30:44 +01:00
parent bffc600775
commit 09d18916bf
22 changed files with 46 additions and 61 deletions

View File

@@ -302,7 +302,7 @@ func TestParseWithMacAddress(t *testing.T) {
t.Fatalf("Expected an error with %v mac-address, got %v", invalidMacAddress, err)
}
config, hostConfig, _ := mustParse(t, validMacAddress)
fmt.Printf("MacAddress: %+v\n", hostConfig)
t.Logf("MacAddress: %+v\n", hostConfig)
assert.Equal(t, "92:d0:c6:0a:29:33", config.MacAddress) //nolint:staticcheck
}

View File

@@ -154,7 +154,7 @@ func TestDockerExecAbort(t *testing.T) {
cancel()
err := <-channel
assert.ErrorIs(t, err, context.Canceled)
require.ErrorIs(t, err, context.Canceled)
conn.AssertExpectations(t)
client.AssertExpectations(t)
@@ -231,7 +231,7 @@ func TestDockerCopyTarStreamErrorInCopyFiles(t *testing.T) {
}
err := cr.CopyTarStream(ctx, "/var/run/act", &bytes.Buffer{})
assert.ErrorIs(t, err, merr)
require.ErrorIs(t, err, merr)
conn.AssertExpectations(t)
client.AssertExpectations(t)
@@ -256,7 +256,7 @@ func TestDockerCopyTarStreamErrorInMkdir(t *testing.T) {
}
err := cr.CopyTarStream(ctx, "/var/run/act", &bytes.Buffer{})
assert.ErrorIs(t, err, merr)
require.ErrorIs(t, err, merr)
conn.AssertExpectations(t)
client.AssertExpectations(t)

View File

@@ -20,7 +20,7 @@ func TestGetSocketAndHostWithSocket(t *testing.T) {
CommonSocketLocations = originalCommonSocketLocations
dockerHost := "unix:///my/docker/host.sock"
socketURI := "/path/to/my.socket"
os.Setenv("DOCKER_HOST", dockerHost)
t.Setenv("DOCKER_HOST", dockerHost)
// Act
ret, err := GetSocketAndHost(socketURI)
@@ -33,7 +33,7 @@ func TestGetSocketAndHostWithSocket(t *testing.T) {
func TestGetSocketAndHostNoSocket(t *testing.T) {
// Arrange
dockerHost := "unix:///my/docker/host.sock"
os.Setenv("DOCKER_HOST", dockerHost)
t.Setenv("DOCKER_HOST", dockerHost)
// Act
ret, err := GetSocketAndHost("")
@@ -64,7 +64,7 @@ func TestGetSocketAndHostDontMount(t *testing.T) {
// Arrange
CommonSocketLocations = originalCommonSocketLocations
dockerHost := "unix:///my/docker/host.sock"
os.Setenv("DOCKER_HOST", dockerHost)
t.Setenv("DOCKER_HOST", dockerHost)
// Act
ret, err := GetSocketAndHost("-")

View File

@@ -38,8 +38,7 @@ func TestCopyDir(t *testing.T) {
}
func TestGetContainerArchive(t *testing.T) {
dir, err := os.MkdirTemp("", "test-host-env-*")
require.NoError(t, err)
dir := t.TempDir()
defer os.RemoveAll(dir)
ctx := context.Background()
e := &HostEnvironment{
@@ -55,7 +54,7 @@ func TestGetContainerArchive(t *testing.T) {
_ = os.MkdirAll(e.ToolCache, 0700)
_ = os.MkdirAll(e.ActPath, 0700)
expectedContent := []byte("sdde/7sh")
err = os.WriteFile(filepath.Join(e.Path, "action.yml"), expectedContent, 0600)
err := os.WriteFile(filepath.Join(e.Path, "action.yml"), expectedContent, 0600)
require.NoError(t, err)
archive, err := e.GetContainerArchive(ctx, e.Path)
require.NoError(t, err)

View File

@@ -35,18 +35,13 @@ func TestContainerPath(t *testing.T) {
{fmt.Sprintf("/mnt/%v/act", rootDriveLetter), "act", rootDrive + "\\"},
} {
if v.workDir != "" {
if err := os.Chdir(v.workDir); err != nil {
log.Error(err)
t.Fail()
}
t.Chdir(v.workDir)
}
assert.Equal(t, v.destinationPath, linuxcontainerext.ToContainerPath(v.sourcePath))
}
if err := os.Chdir(cwd); err != nil {
log.Error(err)
}
t.Chdir(cwd)
} else {
cwd, err := os.Getwd()
if err != nil {