summaryrefslogtreecommitdiffstats
path: root/pkg/runner/container_mock_test.go
blob: 04d6261b1679cfbd667fe00e24dfb33c303ad34d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package runner

import (
	"context"
	"io"

	"github.com/nektos/act/pkg/common"
	"github.com/nektos/act/pkg/container"
	"github.com/stretchr/testify/mock"
)

type containerMock struct {
	mock.Mock
	container.Container
	container.LinuxContainerEnvironmentExtensions
}

func (cm *containerMock) Create(capAdd []string, capDrop []string) common.Executor {
	args := cm.Called(capAdd, capDrop)
	return args.Get(0).(func(context.Context) error)
}

func (cm *containerMock) Pull(forcePull bool) common.Executor {
	args := cm.Called(forcePull)
	return args.Get(0).(func(context.Context) error)
}

func (cm *containerMock) Start(attach bool) common.Executor {
	args := cm.Called(attach)
	return args.Get(0).(func(context.Context) error)
}

func (cm *containerMock) Remove() common.Executor {
	args := cm.Called()
	return args.Get(0).(func(context.Context) error)
}

func (cm *containerMock) Close() common.Executor {
	args := cm.Called()
	return args.Get(0).(func(context.Context) error)
}

func (cm *containerMock) UpdateFromEnv(srcPath string, env *map[string]string) common.Executor {
	args := cm.Called(srcPath, env)
	return args.Get(0).(func(context.Context) error)
}

func (cm *containerMock) UpdateFromImageEnv(env *map[string]string) common.Executor {
	args := cm.Called(env)
	return args.Get(0).(func(context.Context) error)
}

func (cm *containerMock) Copy(destPath string, files ...*container.FileEntry) common.Executor {
	args := cm.Called(destPath, files)
	return args.Get(0).(func(context.Context) error)
}

func (cm *containerMock) CopyDir(destPath string, srcPath string, useGitIgnore bool) common.Executor {
	args := cm.Called(destPath, srcPath, useGitIgnore)
	return args.Get(0).(func(context.Context) error)
}

func (cm *containerMock) Exec(command []string, env map[string]string, user, workdir string) common.Executor {
	args := cm.Called(command, env, user, workdir)
	return args.Get(0).(func(context.Context) error)
}

func (cm *containerMock) GetContainerArchive(ctx context.Context, srcPath string) (io.ReadCloser, error) {
	args := cm.Called(ctx, srcPath)
	err, hasErr := args.Get(1).(error)
	if !hasErr {
		err = nil
	}
	return args.Get(0).(io.ReadCloser), err
}