package plan3test import ( "testing" "amadan.net/oficina/equipo/internal/equipo" "amadan.net/rastrillo/rastrillo/migrate" ) func TestInviteMigration(t *testing.T) { f := inviteUpgradeFixture(t) d := f.DB result, err := migrate.Apply(ctx, d, equipo.BootSchema) must(t, err) if len(result.Applied) != 1 || result.Applied[0] != "equipo/0027_invitations" { t.Fatal(result.Applied) } if f.count(t, "SELECT roster_epoch FROM teams") != 7 || f.count(t, "SELECT revision FROM members") != 4 || f.count(t, "SELECT count(*) FROM audit_events WHERE kind='old.audit'") != 1 { t.Fatal("migration changed history") } if f.count(t, "SELECT count(*) FROM invitations") != 0 { t.Fatal("migration issued invitations") } fresh := newFixture(t) upgraded, err := migrate.Read(ctx, d.Writer()) must(t, err) clean, err := migrate.Read(ctx, fresh.DB.Writer()) must(t, err) if !upgraded.Equal(clean) { t.Fatal(upgraded.Diff(clean)) } result, err = migrate.Apply(ctx, d, equipo.BootSchema) must(t, err) if len(result.Applied) != 0 { t.Fatal("migration repeated") } }