From 6e026dc1ee434c0f9098a8bb664f6398b8cfdc07 Mon Sep 17 00:00:00 2001 From: Aditya Thebe Date: Tue, 7 Jan 2025 17:45:37 +0545 Subject: [PATCH] fix: sporadically failing RLS test The entire test suite is ran with RLS enabled. One of the tests (migration dependency test) ran the migration that disabled RLS. --- tests/migration_dependency_test.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/migration_dependency_test.go b/tests/migration_dependency_test.go index 5c2cad24..ccf44279 100644 --- a/tests/migration_dependency_test.go +++ b/tests/migration_dependency_test.go @@ -9,13 +9,22 @@ import ( "github.com/flanksource/duty/migrate" ) -var _ = Describe("migration dependency", Ordered, func() { +var _ = Describe("migration dependency", Ordered, Serial, func() { var connString string BeforeAll(func() { connString = DefaultContext.Value("db_url").(string) }) + AfterAll(func() { + sqlDB, err := DefaultContext.DB().DB() + Expect(err).To(BeNil()) + + // we re-enable RLS + err = migrate.RunMigrations(sqlDB, api.Config{ConnectionString: connString, EnableRLS: true}) + Expect(err).To(BeNil()) + }) + It("should have no executable scripts", func() { db, err := DefaultContext.DB().DB() Expect(err).To(BeNil())