Skip to content

Commit

Permalink
[Aishwarya|Jenson] use linux cron format for golang cron
Browse files Browse the repository at this point in the history
  • Loading branch information
AishwaryaRK committed Jan 24, 2019
1 parent d092780 commit 8e750da
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions proctord/jobs/schedule/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ func (scheduler *scheduler) Schedule() http.HandlerFunc {
return
}

scheduledJob.Time = fmt.Sprintf("0 %s", scheduledJob.Time)
scheduledJob.ID, err = scheduler.store.InsertScheduledJob(scheduledJob.Name, scheduledJob.Tags, scheduledJob.Time, scheduledJob.NotificationEmails, userEmail, scheduledJob.Group, scheduledJob.Args)
if err != nil {
if strings.Contains(err.Error(), "duplicate key value violates unique constraint") {
Expand Down
6 changes: 3 additions & 3 deletions proctord/jobs/schedule/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (suite *SchedulerTestSuite) TestSuccessfulJobScheduling() {

suite.mockMetadataStore.On("GetJobMetadata", scheduledJob.Name).Return(&metadata.Metadata{}, nil)
insertedScheduledJobID := "123"
suite.mockStore.On("InsertScheduledJob", scheduledJob.Name, scheduledJob.Tags, scheduledJob.Time, scheduledJob.NotificationEmails, userEmail,scheduledJob.Group, scheduledJob.Args).Return(insertedScheduledJobID, nil)
suite.mockStore.On("InsertScheduledJob", scheduledJob.Name, scheduledJob.Tags, "0 * 2 * * *", scheduledJob.NotificationEmails, userEmail,scheduledJob.Group, scheduledJob.Args).Return(insertedScheduledJobID, nil)

suite.testScheduler.Schedule()(responseRecorder, req)

Expand Down Expand Up @@ -250,7 +250,7 @@ func (suite *SchedulerTestSuite) TestUniqnessConstrainOnJobNameAndArg() {
req := httptest.NewRequest("POST", "/schedule", bytes.NewReader(requestBody))

suite.mockMetadataStore.On("GetJobMetadata", scheduledJob.Name).Return(&metadata.Metadata{}, nil)
suite.mockStore.On("InsertScheduledJob", scheduledJob.Name, scheduledJob.Tags, scheduledJob.Time, scheduledJob.NotificationEmails, "",scheduledJob.Group, scheduledJob.Args).Return("", errors.New("pq: duplicate key value violates unique constraint \"unique_jobs_schedule_name_args\""))
suite.mockStore.On("InsertScheduledJob", scheduledJob.Name, scheduledJob.Tags, "0 * 2 * * *", scheduledJob.NotificationEmails, "",scheduledJob.Group, scheduledJob.Args).Return("", errors.New("pq: duplicate key value violates unique constraint \"unique_jobs_schedule_name_args\""))

suite.testScheduler.Schedule()(responseRecorder, req)

Expand All @@ -276,7 +276,7 @@ func (suite *SchedulerTestSuite) TestErrorPersistingScheduledJob() {
req := httptest.NewRequest("POST", "/schedule", bytes.NewReader(requestBody))

suite.mockMetadataStore.On("GetJobMetadata", scheduledJob.Name).Return(&metadata.Metadata{}, nil)
suite.mockStore.On("InsertScheduledJob", scheduledJob.Name, scheduledJob.Tags, scheduledJob.Time, scheduledJob.NotificationEmails, "",scheduledJob.Group, scheduledJob.Args).Return("", errors.New("any-error"))
suite.mockStore.On("InsertScheduledJob", scheduledJob.Name, scheduledJob.Tags, "0 * 2 * * *", scheduledJob.NotificationEmails, "",scheduledJob.Group, scheduledJob.Args).Return("", errors.New("any-error"))

suite.testScheduler.Schedule()(responseRecorder, req)

Expand Down

0 comments on commit 8e750da

Please sign in to comment.