refactor: simplify action function signatures (#1083)

This change reduces the interfaces by removing
obsolete parameters from functions.
Obsolete parameters does not means unused ones, but
parameters which could be retrieved from other parameters
instead.

This should simplify logic and maintainability for these
functions.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
Markus Wolf
2022-03-29 19:42:11 +02:00
committed by GitHub
parent 31d3603173
commit 5f673cbb6d
7 changed files with 109 additions and 99 deletions

View File

@@ -20,8 +20,8 @@ func (sarm *stepActionRemoteMocks) readAction(step *model.Step, actionDir string
return args.Get(0).(*model.Action), args.Error(1)
}
func (sarm *stepActionRemoteMocks) runAction(step actionStep, actionDir string, actionPath string, actionRepository string, actionRef string, localAction bool) common.Executor {
args := sarm.Called(step, actionDir, actionPath, actionRepository, actionRef, localAction)
func (sarm *stepActionRemoteMocks) runAction(step actionStep, actionDir string, remoteAction *remoteAction) common.Executor {
args := sarm.Called(step, actionDir, remoteAction)
return args.Get(0).(func(context.Context) error)
}
@@ -48,7 +48,7 @@ func TestStepActionRemoteTest(t *testing.T) {
sar := &stepActionRemote{
RunContext: &RunContext{
Config: &Config{
GitHubInstance: "https://github.com",
GitHubInstance: "github.com",
},
Run: &model.Run{
JobID: "1",
@@ -79,7 +79,7 @@ func TestStepActionRemoteTest(t *testing.T) {
cm.On("UpdateFromPath", &sar.env).Return(func(ctx context.Context) error { return nil })
sarm.On("readAction", sar.Step, suffixMatcher("act/remote-action@v1"), "", mock.Anything, mock.Anything).Return(&model.Action{}, nil)
sarm.On("runAction", sar, suffixMatcher("act/remote-action@v1"), "", "action", "v1", false).Return(func(ctx context.Context) error { return nil })
sarm.On("runAction", sar, suffixMatcher("act/remote-action@v1"), newRemoteAction(sar.Step.Uses)).Return(func(ctx context.Context) error { return nil })
err := sar.main()(ctx)