| 1 | package equipotest |
| 2 | |
| 3 | import ( |
| 4 | "context" |
| 5 | "testing" |
| 6 | |
| 7 | "amadan.net/oficina/equipo/internal/equipo" |
| 8 | "amadan.net/oficina/equipo/internal/equipo/team" |
| 9 | ) |
| 10 | |
| 11 | func TestReconcileRuntimeStaleGrants(t *testing.T) { |
| 12 | for _, revoked := range []bool{false, true} { |
| 13 | t.Run(map[bool]string{false: "authorized", true: "revoked"}[revoked], func(t *testing.T) { |
| 14 | s, d, x, _, _, req := recoveryRuntime(t) |
| 15 | ctx := context.Background() |
| 16 | scope, h, _ := recoveryJob(t, x, req, "runtime") |
| 17 | executionMust(t, s.SetMember(ctx, ownerActor, "new@example.com", equipo.RoleMember, true, 0)) |
| 18 | executionMust(t, x.Core.Contain(ctx, scope, h.Attempt, "supervisor")) |
| 19 | if revoked { |
| 20 | mustSQL(t, d, "UPDATE members SET active=0 WHERE address=?", "member@example.com") |
| 21 | } |
| 22 | executionMust(t, x.Reconcile(ctx)) |
| 23 | job, err := x.Core.GetJob(ctx, scope) |
| 24 | executionMust(t, err) |
| 25 | if revoked { |
| 26 | if job.State != team.JobCancelled { |
| 27 | t.Fatal("reconcile left revoked job runnable", job.State) |
| 28 | } |
| 29 | } else { |
| 30 | _, err = x.Core.Claim(ctx, scope, "reproduce", "next", "next") |
| 31 | executionMust(t, err) |
| 32 | } |
| 33 | }) |
| 34 | } |
| 35 | } |
| 36 | |