From 9b5ee89cb5236916a47e1f54f353bb3289d6bc9c Mon Sep 17 00:00:00 2001 From: krrrr38 Date: Mon, 16 Jan 2023 10:13:18 +0900 Subject: [PATCH] rename matchers2 --- .../project_command_builder_internal_test.go | 14 +-- server/events/project_command_builder_test.go | 96 +++++++++---------- 2 files changed, 55 insertions(+), 55 deletions(-) diff --git a/server/events/project_command_builder_internal_test.go b/server/events/project_command_builder_internal_test.go index 7e41bebb37..48d5252048 100644 --- a/server/events/project_command_builder_internal_test.go +++ b/server/events/project_command_builder_internal_test.go @@ -11,7 +11,7 @@ import ( "github.com/runatlantis/atlantis/server/core/config/valid" "github.com/runatlantis/atlantis/server/core/terraform/mocks" "github.com/runatlantis/atlantis/server/events/command" - matchers2 "github.com/runatlantis/atlantis/server/events/mocks/matchers" + eventsmatchers "github.com/runatlantis/atlantis/server/events/mocks/matchers" "github.com/runatlantis/atlantis/server/events/models" vcsmocks "github.com/runatlantis/atlantis/server/events/vcs/mocks" "github.com/runatlantis/atlantis/server/logging" @@ -613,9 +613,9 @@ projects: }) workingDir := NewMockWorkingDir() - When(workingDir.Clone(matchers2.AnyLoggingSimpleLogging(), matchers2.AnyModelsRepo(), matchers2.AnyModelsPullRequest(), AnyString())).ThenReturn(tmp, false, nil) + When(workingDir.Clone(eventsmatchers.AnyLoggingSimpleLogging(), eventsmatchers.AnyModelsRepo(), eventsmatchers.AnyModelsPullRequest(), AnyString())).ThenReturn(tmp, false, nil) vcsClient := vcsmocks.NewMockClient() - When(vcsClient.GetModifiedFiles(matchers2.AnyModelsRepo(), matchers2.AnyModelsPullRequest())).ThenReturn([]string{"modules/module/main.tf"}, nil) + When(vcsClient.GetModifiedFiles(eventsmatchers.AnyModelsRepo(), eventsmatchers.AnyModelsPullRequest())).ThenReturn([]string{"modules/module/main.tf"}, nil) // Write and parse the global config file. globalCfgPath := filepath.Join(tmp, "global.yaml") @@ -824,9 +824,9 @@ projects: }) workingDir := NewMockWorkingDir() - When(workingDir.Clone(logging_matchers.AnyLoggingSimpleLogging(), matchers2.AnyModelsRepo(), matchers2.AnyModelsPullRequest(), AnyString())).ThenReturn(tmp, false, nil) + When(workingDir.Clone(logging_matchers.AnyLoggingSimpleLogging(), eventsmatchers.AnyModelsRepo(), eventsmatchers.AnyModelsPullRequest(), AnyString())).ThenReturn(tmp, false, nil) vcsClient := vcsmocks.NewMockClient() - When(vcsClient.GetModifiedFiles(matchers2.AnyModelsRepo(), matchers2.AnyModelsPullRequest())).ThenReturn([]string{"modules/module/main.tf"}, nil) + When(vcsClient.GetModifiedFiles(eventsmatchers.AnyModelsRepo(), eventsmatchers.AnyModelsPullRequest())).ThenReturn([]string{"modules/module/main.tf"}, nil) // Write and parse the global config file. globalCfgPath := filepath.Join(tmp, "global.yaml") @@ -1057,9 +1057,9 @@ workflows: }) workingDir := NewMockWorkingDir() - When(workingDir.Clone(matchers2.AnyLoggingSimpleLogging(), matchers2.AnyModelsRepo(), matchers2.AnyModelsPullRequest(), AnyString())).ThenReturn(tmp, false, nil) + When(workingDir.Clone(eventsmatchers.AnyLoggingSimpleLogging(), eventsmatchers.AnyModelsRepo(), eventsmatchers.AnyModelsPullRequest(), AnyString())).ThenReturn(tmp, false, nil) vcsClient := vcsmocks.NewMockClient() - When(vcsClient.GetModifiedFiles(matchers2.AnyModelsRepo(), matchers2.AnyModelsPullRequest())).ThenReturn([]string{"modules/module/main.tf"}, nil) + When(vcsClient.GetModifiedFiles(eventsmatchers.AnyModelsRepo(), eventsmatchers.AnyModelsPullRequest())).ThenReturn([]string{"modules/module/main.tf"}, nil) // Write and parse the global config file. globalCfgPath := filepath.Join(tmp, "global.yaml") diff --git a/server/events/project_command_builder_test.go b/server/events/project_command_builder_test.go index 90c56009bd..14567bf091 100644 --- a/server/events/project_command_builder_test.go +++ b/server/events/project_command_builder_test.go @@ -8,14 +8,14 @@ import ( "github.com/hashicorp/go-version" . "github.com/petergtz/pegomock" - terraform_mocks "github.com/runatlantis/atlantis/server/core/terraform/mocks" - matchers2 "github.com/runatlantis/atlantis/server/events/mocks/matchers" "github.com/runatlantis/atlantis/server/core/config" "github.com/runatlantis/atlantis/server/core/config/valid" + terraform_mocks "github.com/runatlantis/atlantis/server/core/terraform/mocks" "github.com/runatlantis/atlantis/server/events" "github.com/runatlantis/atlantis/server/events/command" "github.com/runatlantis/atlantis/server/events/mocks" + eventsmatchers "github.com/runatlantis/atlantis/server/events/mocks/matchers" "github.com/runatlantis/atlantis/server/events/models" vcsmocks "github.com/runatlantis/atlantis/server/events/vcs/mocks" "github.com/runatlantis/atlantis/server/logging" @@ -125,7 +125,7 @@ projects: scope, _, _ := metrics.NewLoggingScope(logger, "atlantis") terraformClient := terraform_mocks.NewMockClient() - When(terraformClient.ListAvailableVersions(matchers2.AnyLoggingSimpleLogging())).ThenReturn([]string{}, nil) + When(terraformClient.ListAvailableVersions(eventsmatchers.AnyLoggingSimpleLogging())).ThenReturn([]string{}, nil) for _, c := range cases { t.Run(c.Description, func(t *testing.T) { @@ -135,9 +135,9 @@ projects: }) workingDir := mocks.NewMockWorkingDir() - When(workingDir.Clone(matchers2.AnyLoggingSimpleLogging(), matchers2.AnyModelsRepo(), matchers2.AnyModelsPullRequest(), AnyString())).ThenReturn(tmpDir, false, nil) + When(workingDir.Clone(eventsmatchers.AnyLoggingSimpleLogging(), eventsmatchers.AnyModelsRepo(), eventsmatchers.AnyModelsPullRequest(), AnyString())).ThenReturn(tmpDir, false, nil) vcsClient := vcsmocks.NewMockClient() - When(vcsClient.GetModifiedFiles(matchers2.AnyModelsRepo(), matchers2.AnyModelsPullRequest())).ThenReturn([]string{"main.tf"}, nil) + When(vcsClient.GetModifiedFiles(eventsmatchers.AnyModelsRepo(), eventsmatchers.AnyModelsPullRequest())).ThenReturn([]string{"main.tf"}, nil) if c.AtlantisYAML != "" { err := os.WriteFile(filepath.Join(tmpDir, valid.DefaultAtlantisFile), []byte(c.AtlantisYAML), 0600) Ok(t, err) @@ -404,10 +404,10 @@ projects: }) workingDir := mocks.NewMockWorkingDir() - When(workingDir.Clone(matchers2.AnyLoggingSimpleLogging(), matchers2.AnyModelsRepo(), matchers2.AnyModelsPullRequest(), AnyString())).ThenReturn(tmpDir, false, nil) - When(workingDir.GetWorkingDir(matchers2.AnyModelsRepo(), matchers2.AnyModelsPullRequest(), AnyString())).ThenReturn(tmpDir, nil) + When(workingDir.Clone(eventsmatchers.AnyLoggingSimpleLogging(), eventsmatchers.AnyModelsRepo(), eventsmatchers.AnyModelsPullRequest(), AnyString())).ThenReturn(tmpDir, false, nil) + When(workingDir.GetWorkingDir(eventsmatchers.AnyModelsRepo(), eventsmatchers.AnyModelsPullRequest(), AnyString())).ThenReturn(tmpDir, nil) vcsClient := vcsmocks.NewMockClient() - When(vcsClient.GetModifiedFiles(matchers2.AnyModelsRepo(), matchers2.AnyModelsPullRequest())).ThenReturn([]string{"main.tf"}, nil) + When(vcsClient.GetModifiedFiles(eventsmatchers.AnyModelsRepo(), eventsmatchers.AnyModelsPullRequest())).ThenReturn([]string{"main.tf"}, nil) if c.AtlantisYAML != "" { err := os.WriteFile(filepath.Join(tmpDir, valid.DefaultAtlantisFile), []byte(c.AtlantisYAML), 0600) Ok(t, err) @@ -421,7 +421,7 @@ projects: } terraformClient := terraform_mocks.NewMockClient() - When(terraformClient.ListAvailableVersions(matchers2.AnyLoggingSimpleLogging())).ThenReturn([]string{}, nil) + When(terraformClient.ListAvailableVersions(eventsmatchers.AnyLoggingSimpleLogging())).ThenReturn([]string{}, nil) builder := events.NewProjectCommandBuilder( false, @@ -581,10 +581,10 @@ projects: tmpDir := DirStructure(t, c.DirectoryStructure) workingDir := mocks.NewMockWorkingDir() - When(workingDir.Clone(matchers2.AnyLoggingSimpleLogging(), matchers2.AnyModelsRepo(), matchers2.AnyModelsPullRequest(), AnyString())).ThenReturn(tmpDir, false, nil) - When(workingDir.GetWorkingDir(matchers2.AnyModelsRepo(), matchers2.AnyModelsPullRequest(), AnyString())).ThenReturn(tmpDir, nil) + When(workingDir.Clone(eventsmatchers.AnyLoggingSimpleLogging(), eventsmatchers.AnyModelsRepo(), eventsmatchers.AnyModelsPullRequest(), AnyString())).ThenReturn(tmpDir, false, nil) + When(workingDir.GetWorkingDir(eventsmatchers.AnyModelsRepo(), eventsmatchers.AnyModelsPullRequest(), AnyString())).ThenReturn(tmpDir, nil) vcsClient := vcsmocks.NewMockClient() - When(vcsClient.GetModifiedFiles(matchers2.AnyModelsRepo(), matchers2.AnyModelsPullRequest())).ThenReturn(c.ModifiedFiles, nil) + When(vcsClient.GetModifiedFiles(eventsmatchers.AnyModelsRepo(), eventsmatchers.AnyModelsPullRequest())).ThenReturn(c.ModifiedFiles, nil) if c.AtlantisYAML != "" { err := os.WriteFile(filepath.Join(tmpDir, valid.DefaultAtlantisFile), []byte(c.AtlantisYAML), 0600) Ok(t, err) @@ -598,7 +598,7 @@ projects: } terraformClient := terraform_mocks.NewMockClient() - When(terraformClient.ListAvailableVersions(matchers2.AnyLoggingSimpleLogging())).ThenReturn([]string{}, nil) + When(terraformClient.ListAvailableVersions(eventsmatchers.AnyLoggingSimpleLogging())).ThenReturn([]string{}, nil) builder := events.NewProjectCommandBuilder( false, @@ -766,10 +766,10 @@ projects: tmpDir := DirStructure(t, c.DirStructure) workingDir := mocks.NewMockWorkingDir() - When(workingDir.Clone(matchers2.AnyLoggingSimpleLogging(), matchers2.AnyModelsRepo(), matchers2.AnyModelsPullRequest(), AnyString())).ThenReturn(tmpDir, false, nil) - When(workingDir.GetWorkingDir(matchers2.AnyModelsRepo(), matchers2.AnyModelsPullRequest(), AnyString())).ThenReturn(tmpDir, nil) + When(workingDir.Clone(eventsmatchers.AnyLoggingSimpleLogging(), eventsmatchers.AnyModelsRepo(), eventsmatchers.AnyModelsPullRequest(), AnyString())).ThenReturn(tmpDir, false, nil) + When(workingDir.GetWorkingDir(eventsmatchers.AnyModelsRepo(), eventsmatchers.AnyModelsPullRequest(), AnyString())).ThenReturn(tmpDir, nil) vcsClient := vcsmocks.NewMockClient() - When(vcsClient.GetModifiedFiles(matchers2.AnyModelsRepo(), matchers2.AnyModelsPullRequest())).ThenReturn(c.ModifiedFiles, nil) + When(vcsClient.GetModifiedFiles(eventsmatchers.AnyModelsRepo(), eventsmatchers.AnyModelsPullRequest())).ThenReturn(c.ModifiedFiles, nil) if c.AtlantisYAML != "" { err := os.WriteFile(filepath.Join(tmpDir, valid.DefaultAtlantisFile), []byte(c.AtlantisYAML), 0600) Ok(t, err) @@ -783,7 +783,7 @@ projects: } terraformClient := terraform_mocks.NewMockClient() - When(terraformClient.ListAvailableVersions(matchers2.AnyLoggingSimpleLogging())).ThenReturn([]string{}, nil) + When(terraformClient.ListAvailableVersions(eventsmatchers.AnyLoggingSimpleLogging())).ThenReturn([]string{}, nil) builder := events.NewProjectCommandBuilder( false, @@ -866,8 +866,8 @@ func TestDefaultProjectCommandBuilder_BuildMultiApply(t *testing.T) { workingDir := mocks.NewMockWorkingDir() When(workingDir.GetPullDir( - matchers2.AnyModelsRepo(), - matchers2.AnyModelsPullRequest())). + eventsmatchers.AnyModelsRepo(), + eventsmatchers.AnyModelsPullRequest())). ThenReturn(tmpDir, nil) logger := logging.NewNoopLogger(t) @@ -881,7 +881,7 @@ func TestDefaultProjectCommandBuilder_BuildMultiApply(t *testing.T) { scope, _, _ := metrics.NewLoggingScope(logger, "atlantis") terraformClient := terraform_mocks.NewMockClient() - When(terraformClient.ListAvailableVersions(matchers2.AnyLoggingSimpleLogging())).ThenReturn([]string{}, nil) + When(terraformClient.ListAvailableVersions(eventsmatchers.AnyLoggingSimpleLogging())).ThenReturn([]string{}, nil) builder := events.NewProjectCommandBuilder( false, @@ -952,13 +952,13 @@ projects: Ok(t, err) When(workingDir.Clone( - matchers2.AnyLoggingSimpleLogging(), - matchers2.AnyModelsRepo(), - matchers2.AnyModelsPullRequest(), + eventsmatchers.AnyLoggingSimpleLogging(), + eventsmatchers.AnyModelsRepo(), + eventsmatchers.AnyModelsPullRequest(), AnyString())).ThenReturn(repoDir, false, nil) When(workingDir.GetWorkingDir( - matchers2.AnyModelsRepo(), - matchers2.AnyModelsPullRequest(), + eventsmatchers.AnyModelsRepo(), + eventsmatchers.AnyModelsPullRequest(), AnyString())).ThenReturn(repoDir, nil) globalCfgArgs := valid.GlobalCfgArgs{ @@ -970,7 +970,7 @@ projects: logger := logging.NewNoopLogger(t) scope, _, _ := metrics.NewLoggingScope(logger, "atlantis") terraformClient := terraform_mocks.NewMockClient() - When(terraformClient.ListAvailableVersions(matchers2.AnyLoggingSimpleLogging())).ThenReturn([]string{}, nil) + When(terraformClient.ListAvailableVersions(eventsmatchers.AnyLoggingSimpleLogging())).ThenReturn([]string{}, nil) builder := events.NewProjectCommandBuilder( false, @@ -1041,10 +1041,10 @@ func TestDefaultProjectCommandBuilder_EscapeArgs(t *testing.T) { }) workingDir := mocks.NewMockWorkingDir() - When(workingDir.Clone(matchers2.AnyLoggingSimpleLogging(), matchers2.AnyModelsRepo(), matchers2.AnyModelsPullRequest(), AnyString())).ThenReturn(tmpDir, false, nil) - When(workingDir.GetWorkingDir(matchers2.AnyModelsRepo(), matchers2.AnyModelsPullRequest(), AnyString())).ThenReturn(tmpDir, nil) + When(workingDir.Clone(eventsmatchers.AnyLoggingSimpleLogging(), eventsmatchers.AnyModelsRepo(), eventsmatchers.AnyModelsPullRequest(), AnyString())).ThenReturn(tmpDir, false, nil) + When(workingDir.GetWorkingDir(eventsmatchers.AnyModelsRepo(), eventsmatchers.AnyModelsPullRequest(), AnyString())).ThenReturn(tmpDir, nil) vcsClient := vcsmocks.NewMockClient() - When(vcsClient.GetModifiedFiles(matchers2.AnyModelsRepo(), matchers2.AnyModelsPullRequest())).ThenReturn([]string{"main.tf"}, nil) + When(vcsClient.GetModifiedFiles(eventsmatchers.AnyModelsRepo(), eventsmatchers.AnyModelsPullRequest())).ThenReturn([]string{"main.tf"}, nil) globalCfgArgs := valid.GlobalCfgArgs{ AllowRepoCfg: true, @@ -1054,7 +1054,7 @@ func TestDefaultProjectCommandBuilder_EscapeArgs(t *testing.T) { } terraformClient := terraform_mocks.NewMockClient() - When(terraformClient.ListAvailableVersions(matchers2.AnyLoggingSimpleLogging())).ThenReturn([]string{}, nil) + When(terraformClient.ListAvailableVersions(eventsmatchers.AnyLoggingSimpleLogging())).ThenReturn([]string{}, nil) builder := events.NewProjectCommandBuilder( false, @@ -1190,18 +1190,18 @@ projects: tmpDir := DirStructure(t, testCase.DirStructure) vcsClient := vcsmocks.NewMockClient() - When(vcsClient.GetModifiedFiles(matchers2.AnyModelsRepo(), matchers2.AnyModelsPullRequest())).ThenReturn(testCase.ModifiedFiles, nil) + When(vcsClient.GetModifiedFiles(eventsmatchers.AnyModelsRepo(), eventsmatchers.AnyModelsPullRequest())).ThenReturn(testCase.ModifiedFiles, nil) workingDir := mocks.NewMockWorkingDir() When(workingDir.Clone( - matchers2.AnyLoggingSimpleLogging(), - matchers2.AnyModelsRepo(), - matchers2.AnyModelsPullRequest(), + eventsmatchers.AnyLoggingSimpleLogging(), + eventsmatchers.AnyModelsRepo(), + eventsmatchers.AnyModelsPullRequest(), AnyString())).ThenReturn(tmpDir, false, nil) When(workingDir.GetWorkingDir( - matchers2.AnyModelsRepo(), - matchers2.AnyModelsPullRequest(), + eventsmatchers.AnyModelsRepo(), + eventsmatchers.AnyModelsPullRequest(), AnyString())).ThenReturn(tmpDir, nil) globalCfgArgs := valid.GlobalCfgArgs{ @@ -1212,7 +1212,7 @@ projects: } terraformClient := terraform_mocks.NewMockClient() - When(terraformClient.DetectVersion(matchers2.AnyLoggingSimpleLogging(), AnyString())).Then(func(params []Param) ReturnValues { + When(terraformClient.DetectVersion(eventsmatchers.AnyLoggingSimpleLogging(), AnyString())).Then(func(params []Param) ReturnValues { projectName := filepath.Base(params[1].(string)) testVersion := testCase.Exp[projectName] if testVersion != "" { @@ -1298,9 +1298,9 @@ parallel_plan: true`, for _, c := range cases { RegisterMockTestingT(t) vcsClient := vcsmocks.NewMockClient() - When(vcsClient.GetModifiedFiles(matchers2.AnyModelsRepo(), matchers2.AnyModelsPullRequest())).ThenReturn(c.ModifiedFiles, nil) - When(vcsClient.SupportsSingleFileDownload(matchers2.AnyModelsRepo())).ThenReturn(true) - When(vcsClient.GetFileContent(matchers2.AnyModelsPullRequest(), AnyString())).ThenReturn(true, []byte(c.AtlantisYAML), nil) + When(vcsClient.GetModifiedFiles(eventsmatchers.AnyModelsRepo(), eventsmatchers.AnyModelsPullRequest())).ThenReturn(c.ModifiedFiles, nil) + When(vcsClient.SupportsSingleFileDownload(eventsmatchers.AnyModelsRepo())).ThenReturn(true) + When(vcsClient.GetFileContent(eventsmatchers.AnyModelsPullRequest(), AnyString())).ThenReturn(true, []byte(c.AtlantisYAML), nil) workingDir := mocks.NewMockWorkingDir() logger := logging.NewNoopLogger(t) @@ -1313,7 +1313,7 @@ parallel_plan: true`, } scope, _, _ := metrics.NewLoggingScope(logger, "atlantis") terraformClient := terraform_mocks.NewMockClient() - When(terraformClient.ListAvailableVersions(matchers2.AnyLoggingSimpleLogging())).ThenReturn([]string{}, nil) + When(terraformClient.ListAvailableVersions(eventsmatchers.AnyLoggingSimpleLogging())).ThenReturn([]string{}, nil) builder := events.NewProjectCommandBuilder( false, @@ -1349,7 +1349,7 @@ parallel_plan: true`, }) Ok(t, err) Equals(t, c.ExpectedCtxs, len(actCtxs)) - workingDir.VerifyWasCalled(c.ExpectedClones).Clone(matchers2.AnyLoggingSimpleLogging(), matchers2.AnyModelsRepo(), matchers2.AnyModelsPullRequest(), AnyString()) + workingDir.VerifyWasCalled(c.ExpectedClones).Clone(eventsmatchers.AnyLoggingSimpleLogging(), eventsmatchers.AnyModelsRepo(), eventsmatchers.AnyModelsPullRequest(), AnyString()) } } @@ -1363,9 +1363,9 @@ func TestDefaultProjectCommandBuilder_WithPolicyCheckEnabled_BuildAutoplanComman scope, _, _ := metrics.NewLoggingScope(logger, "atlantis") workingDir := mocks.NewMockWorkingDir() - When(workingDir.Clone(matchers2.AnyLoggingSimpleLogging(), matchers2.AnyModelsRepo(), matchers2.AnyModelsPullRequest(), AnyString())).ThenReturn(tmpDir, false, nil) + When(workingDir.Clone(eventsmatchers.AnyLoggingSimpleLogging(), eventsmatchers.AnyModelsRepo(), eventsmatchers.AnyModelsPullRequest(), AnyString())).ThenReturn(tmpDir, false, nil) vcsClient := vcsmocks.NewMockClient() - When(vcsClient.GetModifiedFiles(matchers2.AnyModelsRepo(), matchers2.AnyModelsPullRequest())).ThenReturn([]string{"main.tf"}, nil) + When(vcsClient.GetModifiedFiles(eventsmatchers.AnyModelsRepo(), eventsmatchers.AnyModelsPullRequest())).ThenReturn([]string{"main.tf"}, nil) globalCfgArgs := valid.GlobalCfgArgs{ AllowRepoCfg: false, @@ -1376,7 +1376,7 @@ func TestDefaultProjectCommandBuilder_WithPolicyCheckEnabled_BuildAutoplanComman globalCfg := valid.NewGlobalCfgFromArgs(globalCfgArgs) terraformClient := terraform_mocks.NewMockClient() - When(terraformClient.ListAvailableVersions(matchers2.AnyLoggingSimpleLogging())).ThenReturn([]string{}, nil) + When(terraformClient.ListAvailableVersions(eventsmatchers.AnyLoggingSimpleLogging())).ThenReturn([]string{}, nil) builder := events.NewProjectCommandBuilder( true, @@ -1448,8 +1448,8 @@ func TestDefaultProjectCommandBuilder_BuildVersionCommand(t *testing.T) { workingDir := mocks.NewMockWorkingDir() When(workingDir.GetPullDir( - matchers2.AnyModelsRepo(), - matchers2.AnyModelsPullRequest())). + eventsmatchers.AnyModelsRepo(), + eventsmatchers.AnyModelsPullRequest())). ThenReturn(tmpDir, nil) logger := logging.NewNoopLogger(t) @@ -1462,7 +1462,7 @@ func TestDefaultProjectCommandBuilder_BuildVersionCommand(t *testing.T) { UnDivergedReq: false, } terraformClient := terraform_mocks.NewMockClient() - When(terraformClient.ListAvailableVersions(matchers2.AnyLoggingSimpleLogging())).ThenReturn([]string{}, nil) + When(terraformClient.ListAvailableVersions(eventsmatchers.AnyLoggingSimpleLogging())).ThenReturn([]string{}, nil) builder := events.NewProjectCommandBuilder( false,