ライブラリ・再生・削除を追加(Range 配信、パスの安全確認、共有ファイル名規則)
This commit is contained in:
@@ -24,6 +24,7 @@ type fakeJobStore struct {
|
||||
registerErr error
|
||||
subscribedCalls int
|
||||
subscribedIDs []string
|
||||
beforeDeleteSucceeded func()
|
||||
err error
|
||||
}
|
||||
|
||||
@@ -212,3 +213,48 @@ func (f *fakeJobStore) DeleteSubscription(_ context.Context, seriesID string) (b
|
||||
delete(f.subscriptions, seriesID)
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func (f *fakeJobStore) ListSucceededJobs(_ context.Context, limit int) ([]store.Job, error) {
|
||||
if f.err != nil {
|
||||
return nil, f.err
|
||||
}
|
||||
var result []store.Job
|
||||
for _, job := range f.jobs {
|
||||
if job.Status == "succeeded" {
|
||||
result = append(result, job)
|
||||
}
|
||||
}
|
||||
sort.Slice(result, func(i, j int) bool { return result[i].ID > result[j].ID })
|
||||
if len(result) > limit {
|
||||
result = result[:limit]
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (f *fakeJobStore) GetSucceededJob(_ context.Context, id int64) (store.Job, error) {
|
||||
if f.err != nil {
|
||||
return store.Job{}, f.err
|
||||
}
|
||||
for _, job := range f.jobs {
|
||||
if job.ID == id && job.Status == "succeeded" {
|
||||
return job, nil
|
||||
}
|
||||
}
|
||||
return store.Job{}, pgx.ErrNoRows
|
||||
}
|
||||
|
||||
func (f *fakeJobStore) DeleteSucceededJob(_ context.Context, id int64) error {
|
||||
if f.beforeDeleteSucceeded != nil {
|
||||
f.beforeDeleteSucceeded()
|
||||
}
|
||||
if f.err != nil {
|
||||
return f.err
|
||||
}
|
||||
for episodeID, job := range f.jobs {
|
||||
if job.ID == id && job.Status == "succeeded" {
|
||||
delete(f.jobs, episodeID)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
return store.ErrInvalidTransition
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user