WIP: convert GORM to sqlc, for jobs/tasks #104304
@ -753,22 +753,10 @@ func TestFetchTaskLogTail(t *testing.T) {
|
|||||||
|
|
||||||
jobID := "18a9b096-d77e-438c-9be2-74397038298b"
|
jobID := "18a9b096-d77e-438c-9be2-74397038298b"
|
||||||
taskID := "2e020eee-20f8-4e95-8dcf-65f7dfc3ebab"
|
taskID := "2e020eee-20f8-4e95-8dcf-65f7dfc3ebab"
|
||||||
dbJob := persistence.Job{
|
|
||||||
UUID: jobID,
|
|
||||||
Name: "test job",
|
|
||||||
Status: api.JobStatusActive,
|
|
||||||
Settings: persistence.StringInterfaceMap{},
|
|
||||||
Metadata: persistence.StringStringMap{},
|
|
||||||
}
|
|
||||||
dbTask := persistence.Task{
|
|
||||||
UUID: taskID,
|
|
||||||
Job: &dbJob,
|
|
||||||
Name: "test task",
|
|
||||||
}
|
|
||||||
|
|
||||||
// The task can be found, but has no on-disk task log.
|
// The task can be found, but has no on-disk task log.
|
||||||
// This should not cause any error, but instead be returned as "no content".
|
// This should not cause any error, but instead be returned as "no content".
|
||||||
mf.persistence.EXPECT().FetchTask(gomock.Any(), taskID).Return(&dbTask, nil)
|
mf.persistence.EXPECT().FetchTaskJobUUID(gomock.Any(), taskID).Return(jobID, nil)
|
||||||
mf.logStorage.EXPECT().Tail(jobID, taskID).
|
mf.logStorage.EXPECT().Tail(jobID, taskID).
|
||||||
Return("", fmt.Errorf("wrapped error: %w", os.ErrNotExist))
|
Return("", fmt.Errorf("wrapped error: %w", os.ErrNotExist))
|
||||||
|
|
||||||
@ -778,7 +766,7 @@ func TestFetchTaskLogTail(t *testing.T) {
|
|||||||
assertResponseNoContent(t, echoCtx)
|
assertResponseNoContent(t, echoCtx)
|
||||||
|
|
||||||
// Check that a 204 No Content is also returned when the task log file on disk exists, but is empty.
|
// Check that a 204 No Content is also returned when the task log file on disk exists, but is empty.
|
||||||
mf.persistence.EXPECT().FetchTask(gomock.Any(), taskID).Return(&dbTask, nil)
|
mf.persistence.EXPECT().FetchTaskJobUUID(gomock.Any(), taskID).Return(jobID, nil)
|
||||||
mf.logStorage.EXPECT().Tail(jobID, taskID).
|
mf.logStorage.EXPECT().Tail(jobID, taskID).
|
||||||
Return("", fmt.Errorf("wrapped error: %w", os.ErrNotExist))
|
Return("", fmt.Errorf("wrapped error: %w", os.ErrNotExist))
|
||||||
|
|
||||||
@ -796,21 +784,9 @@ func TestFetchTaskLogInfo(t *testing.T) {
|
|||||||
|
|
||||||
jobID := "18a9b096-d77e-438c-9be2-74397038298b"
|
jobID := "18a9b096-d77e-438c-9be2-74397038298b"
|
||||||
taskID := "2e020eee-20f8-4e95-8dcf-65f7dfc3ebab"
|
taskID := "2e020eee-20f8-4e95-8dcf-65f7dfc3ebab"
|
||||||
dbJob := persistence.Job{
|
|
||||||
UUID: jobID,
|
|
||||||
Name: "test job",
|
|
||||||
Status: api.JobStatusActive,
|
|
||||||
Settings: persistence.StringInterfaceMap{},
|
|
||||||
Metadata: persistence.StringStringMap{},
|
|
||||||
}
|
|
||||||
dbTask := persistence.Task{
|
|
||||||
UUID: taskID,
|
|
||||||
Job: &dbJob,
|
|
||||||
Name: "test task",
|
|
||||||
}
|
|
||||||
mf.persistence.EXPECT().
|
mf.persistence.EXPECT().
|
||||||
FetchTask(gomock.Any(), taskID).
|
FetchTaskJobUUID(gomock.Any(), taskID).
|
||||||
Return(&dbTask, nil).
|
Return(jobID, nil).
|
||||||
AnyTimes()
|
AnyTimes()
|
||||||
|
|
||||||
// The task can be found, but has no on-disk task log.
|
// The task can be found, but has no on-disk task log.
|
||||||
|
15
internal/manager/api_impl/mocks/api_impl_mock.gen.go
generated
15
internal/manager/api_impl/mocks/api_impl_mock.gen.go
generated
@ -244,6 +244,21 @@ func (mr *MockPersistenceServiceMockRecorder) FetchTaskFailureList(arg0, arg1 in
|
|||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchTaskFailureList", reflect.TypeOf((*MockPersistenceService)(nil).FetchTaskFailureList), arg0, arg1)
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchTaskFailureList", reflect.TypeOf((*MockPersistenceService)(nil).FetchTaskFailureList), arg0, arg1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FetchTaskJobUUID mocks base method.
|
||||||
|
func (m *MockPersistenceService) FetchTaskJobUUID(arg0 context.Context, arg1 string) (string, error) {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
ret := m.ctrl.Call(m, "FetchTaskJobUUID", arg0, arg1)
|
||||||
|
ret0, _ := ret[0].(string)
|
||||||
|
ret1, _ := ret[1].(error)
|
||||||
|
return ret0, ret1
|
||||||
|
}
|
||||||
|
|
||||||
|
// FetchTaskJobUUID indicates an expected call of FetchTaskJobUUID.
|
||||||
|
func (mr *MockPersistenceServiceMockRecorder) FetchTaskJobUUID(arg0, arg1 interface{}) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchTaskJobUUID", reflect.TypeOf((*MockPersistenceService)(nil).FetchTaskJobUUID), arg0, arg1)
|
||||||
|
}
|
||||||
|
|
||||||
// FetchWorker mocks base method.
|
// FetchWorker mocks base method.
|
||||||
func (m *MockPersistenceService) FetchWorker(arg0 context.Context, arg1 string) (*persistence.Worker, error) {
|
func (m *MockPersistenceService) FetchWorker(arg0 context.Context, arg1 string) (*persistence.Worker, error) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
|
Loading…
Reference in New Issue
Block a user