@@ -167,7 +167,13 @@ func TestPostgRESTPreflight_MissingSchema(t *testing.T) {
167167 ctx , cancel := context .WithTimeout (context .Background (), 10 * time .Minute )
168168 defer cancel ()
169169
170+ // Create the database without any services first (this must succeed).
170171 db := fixture .NewDatabaseFixture (ctx , t , & controlplane.CreateDatabaseRequest {
172+ Spec : postgrestBaseSpec ("test_postgrest_preflight_schema" , []string {host1 }, nil ),
173+ })
174+
175+ // Adding PostgREST with a nonexistent schema must cause the task to fail.
176+ err := db .Update (ctx , UpdateOptions {
171177 Spec : postgrestBaseSpec (
172178 "test_postgrest_preflight_schema" ,
173179 []string {host1 },
@@ -178,17 +184,8 @@ func TestPostgRESTPreflight_MissingSchema(t *testing.T) {
178184 },
179185 ),
180186 })
181-
182- // The database itself provisions; only the PostgREST task fails.
183- require .NoError (t , db .Refresh (ctx ))
184-
185- // Service instance should not reach running.
186- for _ , si := range db .ServiceInstances {
187- if si .ServiceID == "postgrest-api" {
188- assert .NotEqual (t , "running" , si .State ,
189- "service should not reach running when schema is missing" )
190- }
191- }
187+ require .Error (t , err , "expected update task to fail due to missing schema" )
188+ assert .Contains (t , err .Error (), "nonexistent_schema" , "error should mention the missing schema" )
192189}
193190
194191// TestPostgRESTPreflight_MissingAnonRole verifies the preflight check rejects
@@ -201,7 +198,13 @@ func TestPostgRESTPreflight_MissingAnonRole(t *testing.T) {
201198 ctx , cancel := context .WithTimeout (context .Background (), 10 * time .Minute )
202199 defer cancel ()
203200
201+ // Create the database without any services first (this must succeed).
204202 db := fixture .NewDatabaseFixture (ctx , t , & controlplane.CreateDatabaseRequest {
203+ Spec : postgrestBaseSpec ("test_postgrest_preflight_role" , []string {host1 }, nil ),
204+ })
205+
206+ // Adding PostgREST with a nonexistent anon role must cause the task to fail.
207+ err := db .Update (ctx , UpdateOptions {
205208 Spec : postgrestBaseSpec (
206209 "test_postgrest_preflight_role" ,
207210 []string {host1 },
@@ -212,15 +215,8 @@ func TestPostgRESTPreflight_MissingAnonRole(t *testing.T) {
212215 },
213216 ),
214217 })
215-
216- require .NoError (t , db .Refresh (ctx ))
217-
218- for _ , si := range db .ServiceInstances {
219- if si .ServiceID == "postgrest-api" {
220- assert .NotEqual (t , "running" , si .State ,
221- "service should not reach running when anon role is missing" )
222- }
223- }
218+ require .Error (t , err , "expected update task to fail due to missing anon role" )
219+ assert .Contains (t , err .Error (), "nonexistent_role" , "error should mention the missing role" )
224220}
225221
226222// TestPostgRESTHealthCheck verifies the service responds to HTTP requests once running.
0 commit comments