Initial Backupper Unraid plugin

This commit is contained in:
Mikei386
2026-06-13 22:07:31 +02:00
commit 5352a9da22
39 changed files with 3167 additions and 0 deletions
+30
View File
@@ -0,0 +1,30 @@
package queue
import (
"context"
"testing"
"time"
"github.com/backupper-unraid/backupper/internal/model"
)
func TestQueueDeduplicatesJobAndRunsTask(t *testing.T) {
done := make(chan struct{})
q := New(func(_ context.Context, run model.Run) model.Run { run.Status = "success"; close(done); return run }, nil)
run := model.Run{ID: "one", JobID: "job", TaskType: "backup", CreatedAt: time.Now()}
if err := q.Enqueue(run); err != nil {
t.Fatal(err)
}
if err := q.Enqueue(model.Run{ID: "two", JobID: "job"}); err != ErrDuplicate {
t.Fatalf("duplicate error = %v", err)
}
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
go q.Run(ctx)
select {
case <-done:
case <-time.After(time.Second):
t.Fatal("queue did not execute task")
}
q.Stop()
}