fix: remote docker actions new action cache and dry run mode (#2513)

* fixes

* Add TestDockerCopyTarStreamDryRun

* increase coverage a bit

* fixup

* fixup

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
ChristopherHX
2025-02-25 03:28:17 +01:00
committed by GitHub
parent 404620bd4c
commit 95e411da06
6 changed files with 50 additions and 12 deletions

View File

@@ -14,6 +14,7 @@ import (
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/client"
"github.com/nektos/act/pkg/common"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
)
@@ -195,6 +196,28 @@ func TestDockerCopyTarStream(t *testing.T) {
client.AssertExpectations(t)
}
func TestDockerCopyTarStreamDryRun(t *testing.T) {
ctx := common.WithDryrun(context.Background(), true)
conn := &mockConn{}
client := &mockDockerClient{}
client.AssertNotCalled(t, "CopyToContainer", ctx, "123", "/", mock.Anything, mock.AnythingOfType("container.CopyToContainerOptions"))
client.AssertNotCalled(t, "CopyToContainer", ctx, "123", "/var/run/act", mock.Anything, mock.AnythingOfType("container.CopyToContainerOptions"))
cr := &containerReference{
id: "123",
cli: client,
input: &NewContainerInput{
Image: "image",
},
}
_ = cr.CopyTarStream(ctx, "/var/run/act", &bytes.Buffer{})
conn.AssertExpectations(t)
client.AssertExpectations(t)
}
func TestDockerCopyTarStreamErrorInCopyFiles(t *testing.T) {
ctx := context.Background()