package equipotest import ( "context" "testing" "amadan.net/oficina/equipo/internal/equipo" "amadan.net/oficina/equipo/internal/equipo/team" ) func TestReconcileRuntimeStaleGrants(t *testing.T) { for _, revoked := range []bool{false, true} { t.Run(map[bool]string{false: "authorized", true: "revoked"}[revoked], func(t *testing.T) { s, d, x, _, _, req := recoveryRuntime(t) ctx := context.Background() scope, h, _ := recoveryJob(t, x, req, "runtime") executionMust(t, s.SetMember(ctx, ownerActor, "new@example.com", equipo.RoleMember, true, 0)) executionMust(t, x.Core.Contain(ctx, scope, h.Attempt, "supervisor")) if revoked { mustSQL(t, d, "UPDATE members SET active=0 WHERE address=?", "member@example.com") } executionMust(t, x.Reconcile(ctx)) job, err := x.Core.GetJob(ctx, scope) executionMust(t, err) if revoked { if job.State != team.JobCancelled { t.Fatal("reconcile left revoked job runnable", job.State) } } else { _, err = x.Core.Claim(ctx, scope, "reproduce", "next", "next") executionMust(t, err) } }) } }