feat(backend): implement task creation and admin web

This commit is contained in:
QiuSW
2026-07-26 14:03:32 +08:00
parent 2b265c92fc
commit c5d3b215ff
58 changed files with 8773 additions and 83 deletions
@@ -27,10 +27,13 @@ func TestRunnerSupportsUpStatusDownAndIdempotentUp(t *testing.T) {
if err != nil {
t.Fatalf("Up() error = %v", err)
}
if applied != 1 {
t.Fatalf("Up() applied = %d, want 1", applied)
if applied != 2 {
t.Fatalf("Up() applied = %d, want 2", applied)
}
assertStatus(t, runner, true)
assertStatuses(t, runner, map[int64]bool{
1: true,
2: true,
})
applied, err = runner.Up(context.Background())
if err != nil {
@@ -43,7 +46,10 @@ func TestRunnerSupportsUpStatusDownAndIdempotentUp(t *testing.T) {
if err := runner.Down(context.Background()); err != nil {
t.Fatalf("Down() error = %v", err)
}
assertStatus(t, runner, false)
assertStatuses(t, runner, map[int64]bool{
1: true,
2: false,
})
applied, err = runner.Up(context.Background())
if err != nil {
@@ -52,18 +58,37 @@ func TestRunnerSupportsUpStatusDownAndIdempotentUp(t *testing.T) {
if applied != 1 {
t.Fatalf("final Up() applied = %d, want 1", applied)
}
assertStatuses(t, runner, map[int64]bool{
1: true,
2: true,
})
}
func assertStatus(t *testing.T, runner *Runner, applied bool) {
func assertStatuses(
t *testing.T,
runner *Runner,
want map[int64]bool,
) {
t.Helper()
statuses, err := runner.Status(context.Background())
if err != nil {
t.Fatalf("Status() error = %v", err)
}
if len(statuses) != 1 {
t.Fatalf("Status() count = %d, want 1", len(statuses))
if len(statuses) != len(want) {
t.Fatalf("Status() count = %d, want %d", len(statuses), len(want))
}
if statuses[0].Version != 1 || statuses[0].Applied != applied {
t.Fatalf("Status() = %+v", statuses[0])
for _, status := range statuses {
applied, ok := want[status.Version]
if !ok {
t.Fatalf("unexpected migration status = %+v", status)
}
if status.Applied != applied {
t.Fatalf(
"migration %d applied = %t, want %t",
status.Version,
status.Applied,
applied,
)
}
}
}