Skip to content

Commit

Permalink
[bimo.horizon] Add missing mocks
Browse files Browse the repository at this point in the history
  • Loading branch information
Bimo Horizon committed Aug 13, 2019
1 parent b387375 commit 0e849f5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
18 changes: 9 additions & 9 deletions internal/app/service/execution/service/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,6 @@ func NewExecutionService(
}
}

func (service *executionService) update(executionContext model.ExecutionContext) {
err := service.repository.UpdateStatus(executionContext.ExecutionID, executionContext.Status)
logger.LogErrors(err, "update execution context status", executionContext)
if len(executionContext.Output) > 0 {
err = service.repository.UpdateJobOutput(executionContext.ExecutionID, executionContext.Output)
logger.LogErrors(err, "update execution context output", executionContext)
}
}

func (service *executionService) StreamJobLogs(executionName string, waitTime time.Duration) (io.ReadCloser, error) {
err := service.kubernetesClient.WaitForReadyJob(executionName, waitTime)
if err != nil {
Expand Down Expand Up @@ -130,6 +121,15 @@ func (service *executionService) insertContext(context model.ExecutionContext) {
logger.LogErrors(err, "save execution context to db", context)
}

func (service *executionService) update(executionContext model.ExecutionContext) {
err := service.repository.UpdateStatus(executionContext.ExecutionID, executionContext.Status)
logger.LogErrors(err, "update execution context status", executionContext)
if len(executionContext.Output) > 0 {
err = service.repository.UpdateJobOutput(executionContext.ExecutionID, executionContext.Output)
logger.LogErrors(err, "update execution context output", executionContext)
}
}

func (service *executionService) watchProcess(context model.ExecutionContext) {

waitTime := config.KubeLogProcessWaitTime() * time.Second
Expand Down
9 changes: 6 additions & 3 deletions internal/app/service/execution/service/execution_mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@ func (mockService *MockExecutionService) ExecuteWithCommand(jobName string, user
return arguments.Get(0).(*model.ExecutionContext), arguments.String(1), arguments.Error(2)
}

func (mockService *MockExecutionService) save(executionContext model.ExecutionContext) error {
args := mockService.Called(executionContext)
return args.Error(0)
func (mockService *MockExecutionService) update(executionContext model.ExecutionContext) {
mockService.Called(executionContext)
}

func (mockService *MockExecutionService) insertContext(executionContext model.ExecutionContext) {
mockService.Called(executionContext)
}

func (mockService *MockExecutionService) StreamJobLogs(executionName string, waitTime time.Duration) (io.ReadCloser, error) {
Expand Down

0 comments on commit 0e849f5

Please sign in to comment.