From 43ebee31752f5c1b6c70c9a9e7fa7a2defbc44e2 Mon Sep 17 00:00:00 2001 From: Luke Kysow <1034429+lkysow@users.noreply.github.com> Date: Mon, 25 May 2020 15:09:51 -0700 Subject: [PATCH] Draining cleanup --- server/events/command_runner_test.go | 4 +- server/events/drainer.go | 2 +- server/events/mocks/mock_drainer.go | 177 --------------------------- 3 files changed, 2 insertions(+), 181 deletions(-) delete mode 100644 server/events/mocks/mock_drainer.go diff --git a/server/events/command_runner_test.go b/server/events/command_runner_test.go index ab0f23a86..e90794d96 100644 --- a/server/events/command_runner_test.go +++ b/server/events/command_runner_test.go @@ -33,7 +33,6 @@ import ( . "github.com/runatlantis/atlantis/testing" ) -var commitStatusUpdater *mocks.MockCommitStatusUpdater var projectCommandBuilder *mocks.MockProjectCommandBuilder var projectCommandRunner *mocks.MockProjectCommandRunner var eventParsing *mocks.MockEventParsing @@ -48,7 +47,6 @@ var drainer *events.Drainer func setup(t *testing.T) *vcsmocks.MockClient { RegisterMockTestingT(t) - commitStatusUpdater = mocks.NewMockCommitStatusUpdater() projectCommandBuilder = mocks.NewMockProjectCommandBuilder() eventParsing = mocks.NewMockEventParsing() vcsClient := vcsmocks.NewMockClient() @@ -66,7 +64,7 @@ func setup(t *testing.T) *vcsmocks.MockClient { ThenReturn(pullLogger) ch = events.DefaultCommandRunner{ VCSClient: vcsClient, - CommitStatusUpdater: commitStatusUpdater, + CommitStatusUpdater: &events.DefaultCommitStatusUpdater{vcsClient, "atlantis"}, EventParser: eventParsing, MarkdownRenderer: &events.MarkdownRenderer{}, GithubPullGetter: githubGetter, diff --git a/server/events/drainer.go b/server/events/drainer.go index ff1fb291d..3ac4238fa 100644 --- a/server/events/drainer.go +++ b/server/events/drainer.go @@ -19,7 +19,7 @@ type DrainStatus struct { InProgressOps int } -// StartOp tries to start a new operation. It returns false is Atlantis is +// StartOp tries to start a new operation. It returns false if Atlantis is // shutting down. func (d *Drainer) StartOp() bool { d.mutex.Lock() diff --git a/server/events/mocks/mock_drainer.go b/server/events/mocks/mock_drainer.go deleted file mode 100644 index f99015d64..000000000 --- a/server/events/mocks/mock_drainer.go +++ /dev/null @@ -1,177 +0,0 @@ -// Code generated by pegomock. DO NOT EDIT. -// Source: github.com/runatlantis/atlantis/server/events (interfaces: Drainer) - -package mocks - -import ( - pegomock "github.com/petergtz/pegomock" - events "github.com/runatlantis/atlantis/server/events" - "reflect" - "time" -) - -type MockDrainer struct { - fail func(message string, callerSkip ...int) -} - -func NewMockDrainer(options ...pegomock.Option) *MockDrainer { - mock := &MockDrainer{} - for _, option := range options { - option.Apply(mock) - } - return mock -} - -func (mock *MockDrainer) SetFailHandler(fh pegomock.FailHandler) { mock.fail = fh } -func (mock *MockDrainer) FailHandler() pegomock.FailHandler { return mock.fail } - -func (mock *MockDrainer) GetStatus() events.DrainStatus { - if mock == nil { - panic("mock must not be nil. Use myMock := NewMockDrainer().") - } - params := []pegomock.Param{} - result := pegomock.GetGenericMockFrom(mock).Invoke("GetStatus", params, []reflect.Type{reflect.TypeOf((*events.DrainStatus)(nil)).Elem()}) - var ret0 events.DrainStatus - if len(result) != 0 { - if result[0] != nil { - ret0 = result[0].(events.DrainStatus) - } - } - return ret0 -} - -func (mock *MockDrainer) RemoveOngoingOperation() { - if mock == nil { - panic("mock must not be nil. Use myMock := NewMockDrainer().") - } - params := []pegomock.Param{} - pegomock.GetGenericMockFrom(mock).Invoke("OpDone", params, []reflect.Type{}) -} - -func (mock *MockDrainer) StartDrain() { - if mock == nil { - panic("mock must not be nil. Use myMock := NewMockDrainer().") - } - params := []pegomock.Param{} - pegomock.GetGenericMockFrom(mock).Invoke("ShutdownBlocking", params, []reflect.Type{}) -} - -func (mock *MockDrainer) TryAddNewOngoingOperation() bool { - if mock == nil { - panic("mock must not be nil. Use myMock := NewMockDrainer().") - } - params := []pegomock.Param{} - result := pegomock.GetGenericMockFrom(mock).Invoke("StartOp", params, []reflect.Type{reflect.TypeOf((*bool)(nil)).Elem()}) - var ret0 bool - if len(result) != 0 { - if result[0] != nil { - ret0 = result[0].(bool) - } - } - return ret0 -} - -func (mock *MockDrainer) VerifyWasCalledOnce() *VerifierMockDrainer { - return &VerifierMockDrainer{ - mock: mock, - invocationCountMatcher: pegomock.Times(1), - } -} - -func (mock *MockDrainer) VerifyWasCalled(invocationCountMatcher pegomock.Matcher) *VerifierMockDrainer { - return &VerifierMockDrainer{ - mock: mock, - invocationCountMatcher: invocationCountMatcher, - } -} - -func (mock *MockDrainer) VerifyWasCalledInOrder(invocationCountMatcher pegomock.Matcher, inOrderContext *pegomock.InOrderContext) *VerifierMockDrainer { - return &VerifierMockDrainer{ - mock: mock, - invocationCountMatcher: invocationCountMatcher, - inOrderContext: inOrderContext, - } -} - -func (mock *MockDrainer) VerifyWasCalledEventually(invocationCountMatcher pegomock.Matcher, timeout time.Duration) *VerifierMockDrainer { - return &VerifierMockDrainer{ - mock: mock, - invocationCountMatcher: invocationCountMatcher, - timeout: timeout, - } -} - -type VerifierMockDrainer struct { - mock *MockDrainer - invocationCountMatcher pegomock.Matcher - inOrderContext *pegomock.InOrderContext - timeout time.Duration -} - -func (verifier *VerifierMockDrainer) GetStatus() *MockDrainer_GetStatus_OngoingVerification { - params := []pegomock.Param{} - methodInvocations := pegomock.GetGenericMockFrom(verifier.mock).Verify(verifier.inOrderContext, verifier.invocationCountMatcher, "GetStatus", params, verifier.timeout) - return &MockDrainer_GetStatus_OngoingVerification{mock: verifier.mock, methodInvocations: methodInvocations} -} - -type MockDrainer_GetStatus_OngoingVerification struct { - mock *MockDrainer - methodInvocations []pegomock.MethodInvocation -} - -func (c *MockDrainer_GetStatus_OngoingVerification) GetCapturedArguments() { -} - -func (c *MockDrainer_GetStatus_OngoingVerification) GetAllCapturedArguments() { -} - -func (verifier *VerifierMockDrainer) RemoveOngoingOperation() *MockDrainer_RemoveOngoingOperation_OngoingVerification { - params := []pegomock.Param{} - methodInvocations := pegomock.GetGenericMockFrom(verifier.mock).Verify(verifier.inOrderContext, verifier.invocationCountMatcher, "OpDone", params, verifier.timeout) - return &MockDrainer_RemoveOngoingOperation_OngoingVerification{mock: verifier.mock, methodInvocations: methodInvocations} -} - -type MockDrainer_RemoveOngoingOperation_OngoingVerification struct { - mock *MockDrainer - methodInvocations []pegomock.MethodInvocation -} - -func (c *MockDrainer_RemoveOngoingOperation_OngoingVerification) GetCapturedArguments() { -} - -func (c *MockDrainer_RemoveOngoingOperation_OngoingVerification) GetAllCapturedArguments() { -} - -func (verifier *VerifierMockDrainer) StartDrain() *MockDrainer_StartDrain_OngoingVerification { - params := []pegomock.Param{} - methodInvocations := pegomock.GetGenericMockFrom(verifier.mock).Verify(verifier.inOrderContext, verifier.invocationCountMatcher, "ShutdownBlocking", params, verifier.timeout) - return &MockDrainer_StartDrain_OngoingVerification{mock: verifier.mock, methodInvocations: methodInvocations} -} - -type MockDrainer_StartDrain_OngoingVerification struct { - mock *MockDrainer - methodInvocations []pegomock.MethodInvocation -} - -func (c *MockDrainer_StartDrain_OngoingVerification) GetCapturedArguments() { -} - -func (c *MockDrainer_StartDrain_OngoingVerification) GetAllCapturedArguments() { -} - -func (verifier *VerifierMockDrainer) TryAddNewOngoingOperation() *MockDrainer_TryAddNewOngoingOperation_OngoingVerification { - params := []pegomock.Param{} - methodInvocations := pegomock.GetGenericMockFrom(verifier.mock).Verify(verifier.inOrderContext, verifier.invocationCountMatcher, "StartOp", params, verifier.timeout) - return &MockDrainer_TryAddNewOngoingOperation_OngoingVerification{mock: verifier.mock, methodInvocations: methodInvocations} -} - -type MockDrainer_TryAddNewOngoingOperation_OngoingVerification struct { - mock *MockDrainer - methodInvocations []pegomock.MethodInvocation -} - -func (c *MockDrainer_TryAddNewOngoingOperation_OngoingVerification) GetCapturedArguments() { -} - -func (c *MockDrainer_TryAddNewOngoingOperation_OngoingVerification) GetAllCapturedArguments() { -}