@webstudio-is/postgrest 0.252.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,808 @@
1
+ BEGIN;
2
+
3
+ SET
4
+ LOCAL search_path = pgtap,
5
+ public;
6
+
7
+ -- Initialize the testing environment without planning any specific number of tests
8
+ SELECT
9
+ no_plan();
10
+
11
+ --------------------------------------------------------------------------------
12
+ -- Setup: Insert Initial Data
13
+ --------------------------------------------------------------------------------
14
+ -- Insert a new user into the User table
15
+ INSERT INTO
16
+ "public"."User" ("id", "createdAt", "email", "username")
17
+ VALUES
18
+ (
19
+ 'user1',
20
+ '2023-01-01 00:00:00+00',
21
+ 'user1@example.com',
22
+ 'user1'
23
+ );
24
+
25
+ -- Insert projects associated with the user
26
+ INSERT INTO
27
+ "public"."Project" (
28
+ "id",
29
+ "title",
30
+ "domain",
31
+ "userId",
32
+ "isDeleted",
33
+ "createdAt"
34
+ )
35
+ VALUES
36
+ (
37
+ 'project1',
38
+ 'Project One',
39
+ '517cce32-9af3-project1-domain1',
40
+ 'user1',
41
+ false,
42
+ '2023-01-01 00:00:00+00'
43
+ ),
44
+ (
45
+ 'project2',
46
+ 'Project Two',
47
+ '517cce32-9af3-project2-domain1',
48
+ 'user1',
49
+ false,
50
+ '2023-01-01 00:00:00+00'
51
+ );
52
+
53
+ -- Insert builds with different deployment formats
54
+ INSERT INTO
55
+ "public"."Build" (
56
+ "id",
57
+ "createdAt",
58
+ "pages",
59
+ "projectId",
60
+ "deployment",
61
+ "updatedAt",
62
+ "publishStatus"
63
+ )
64
+ VALUES
65
+ -- Old deployment format: includes projectDomain
66
+ (
67
+ 'build1',
68
+ '2023-01-01 00:00:00+00',
69
+ 'home',
70
+ 'project1',
71
+ '{"projectDomain": "517cce32-9af3-project1-domain1", "domains": [""]}' :: text,
72
+ '2023-01-01 00:00:00+00',
73
+ 'PUBLISHED'
74
+ ),
75
+ (
76
+ 'build1-old',
77
+ '2022-01-01 00:00:00+00',
78
+ 'home',
79
+ 'project1',
80
+ '{"projectDomain": "517cce32-9af3-project1-domain1", "domains": [""]}' :: text,
81
+ '2022-01-01 00:00:00+00',
82
+ 'PUBLISHED'
83
+ ),
84
+ (
85
+ 'build1-newest-wrong-domain',
86
+ '2024-01-01 00:00:00+00',
87
+ 'home',
88
+ 'project1',
89
+ '{"projectDomain": "project-wrong", "domains": [""]}' :: text,
90
+ '2024-01-01 00:00:00+00',
91
+ 'PUBLISHED'
92
+ ),
93
+ -- New deployment format: domains array only
94
+ (
95
+ 'build2',
96
+ '2023-01-02 00:00:00+00',
97
+ 'home',
98
+ 'project2',
99
+ '{"domains": ["517cce32-9af3-project2-domain1"]}' :: text,
100
+ '2023-01-02 00:00:00+00',
101
+ 'PENDING'
102
+ ),
103
+ (
104
+ 'build2-old',
105
+ '2022-01-02 00:00:00+00',
106
+ 'home',
107
+ 'project2',
108
+ '{"domains": ["517cce32-9af3-project2-domain1"]}' :: text,
109
+ '2022-01-02 00:00:00+00',
110
+ 'PENDING'
111
+ );
112
+
113
+ --------------------------------------------------------------------------------
114
+ -- Test Case 1: Verify Latest Build Retrieval Using Old Deployment Format (projectDomain)
115
+ --------------------------------------------------------------------------------
116
+ SELECT
117
+ is (
118
+ (
119
+ SELECT
120
+ ARRAY ["buildId", "domain"]
121
+ FROM
122
+ "public"."latestBuildVirtual"(
123
+ (
124
+ SELECT
125
+ (p.*) :: "Project"
126
+ FROM
127
+ "public"."Project" p
128
+ WHERE
129
+ p."id" = 'project1'
130
+ )
131
+ )
132
+ ),
133
+ ARRAY ['build1', '517cce32-9af3-project1-domain1'],
134
+ 'Test Case 1.1: Should return the latest build for project1 with domain matching projectDomain.'
135
+ );
136
+
137
+ SELECT
138
+ is (
139
+ (
140
+ SELECT
141
+ ARRAY ["buildId", "domain"]
142
+ FROM
143
+ "public"."latestProjectDomainBuildVirtual"(
144
+ (
145
+ SELECT
146
+ (p.*) :: "Project"
147
+ FROM
148
+ "public"."Project" p
149
+ WHERE
150
+ p."id" = 'project1'
151
+ )
152
+ )
153
+ ),
154
+ ARRAY ['build1', '517cce32-9af3-project1-domain1'],
155
+ 'Test Case 1.2: Should return the latest build for project1 with domain matching projectDomain.'
156
+ );
157
+
158
+ --------------------------------------------------------------------------------
159
+ -- Test Case 2: Verify Latest Build Retrieval Using New Deployment Format (domains array)
160
+ --------------------------------------------------------------------------------
161
+ SELECT
162
+ is (
163
+ (
164
+ SELECT
165
+ "buildId"
166
+ FROM
167
+ "public"."latestBuildVirtual"(
168
+ (
169
+ SELECT
170
+ (p.*) :: "Project"
171
+ FROM
172
+ "public"."Project" p
173
+ WHERE
174
+ p."id" = 'project2'
175
+ )
176
+ )
177
+ ),
178
+ 'build2',
179
+ 'Test Case 2.1: Should return the latest build for project2 with domain present in domains array.'
180
+ );
181
+
182
+ SELECT
183
+ is (
184
+ (
185
+ SELECT
186
+ "buildId"
187
+ FROM
188
+ "public"."latestProjectDomainBuildVirtual"(
189
+ (
190
+ SELECT
191
+ (p.*) :: "Project"
192
+ FROM
193
+ "public"."Project" p
194
+ WHERE
195
+ p."id" = 'project2'
196
+ )
197
+ )
198
+ ),
199
+ 'build2',
200
+ 'Test Case 2.2: Should return the latest build for project2 domain with domain present in domains array.'
201
+ );
202
+
203
+ --------------------------------------------------------------------------------
204
+ -- Test Case 3: Update Project Domain and Verify No Build Exists for the New Domain
205
+ --------------------------------------------------------------------------------
206
+ -- Update project1's domain to a new domain
207
+ UPDATE
208
+ "public"."Project"
209
+ SET
210
+ "domain" = 'project1-domain2'
211
+ WHERE
212
+ "id" = 'project1';
213
+
214
+ -- Verify that no build exists for the updated domain
215
+ SELECT
216
+ is (
217
+ (
218
+ SELECT
219
+ COUNT(*) :: integer
220
+ FROM
221
+ "public"."latestBuildVirtual"(
222
+ (
223
+ SELECT
224
+ (p.*) :: "Project"
225
+ FROM
226
+ "public"."Project" p
227
+ WHERE
228
+ p."id" = 'project1'
229
+ )
230
+ )
231
+ ),
232
+ 0,
233
+ 'Test Case 3.1: Should return 0 as no build exists for the updated domain project1-domain2.'
234
+ );
235
+
236
+ SELECT
237
+ is (
238
+ (
239
+ SELECT
240
+ COUNT(*) :: integer
241
+ FROM
242
+ "public"."latestProjectDomainBuildVirtual"(
243
+ (
244
+ SELECT
245
+ (p.*) :: "Project"
246
+ FROM
247
+ "public"."Project" p
248
+ WHERE
249
+ p."id" = 'project1'
250
+ )
251
+ )
252
+ ),
253
+ 0,
254
+ 'Test Case 3.2: Should return 0 as no build exists for the updated domain project1-domain2.'
255
+ );
256
+
257
+ --------------------------------------------------------------------------------
258
+ -- Test Case 4: Insert a New Build with the Updated Domain and Verify Retrieval
259
+ --------------------------------------------------------------------------------
260
+ -- Insert a new build associated with the updated domain
261
+ INSERT INTO
262
+ "public"."Build" (
263
+ "id",
264
+ "createdAt",
265
+ "pages",
266
+ "projectId",
267
+ "deployment",
268
+ "updatedAt",
269
+ "publishStatus"
270
+ )
271
+ VALUES
272
+ (
273
+ 'build1-for-domain2',
274
+ '2023-01-01 00:00:00+00',
275
+ 'home',
276
+ 'project1',
277
+ '{"domains": ["some-other-domain.com", "project1-domain2"]}' :: text,
278
+ '2023-01-01 00:00:00+00',
279
+ 'PUBLISHED'
280
+ );
281
+
282
+ -- Verify that the latest build now reflects the updated domain
283
+ SELECT
284
+ is (
285
+ (
286
+ SELECT
287
+ ARRAY ["buildId", "domain"]
288
+ FROM
289
+ "public"."latestBuildVirtual"(
290
+ (
291
+ SELECT
292
+ (p.*) :: "Project"
293
+ FROM
294
+ "public"."Project" p
295
+ WHERE
296
+ p."id" = 'project1'
297
+ )
298
+ )
299
+ ),
300
+ ARRAY ['build1-for-domain2','project1-domain2'],
301
+ 'Test Case 4.1: Should return the latest build for project1 with the updated domain in domains array.'
302
+ );
303
+
304
+ SELECT
305
+ is (
306
+ (
307
+ SELECT
308
+ ARRAY ["buildId", "domain"]
309
+ FROM
310
+ "public"."latestProjectDomainBuildVirtual"(
311
+ (
312
+ SELECT
313
+ (p.*) :: "Project"
314
+ FROM
315
+ "public"."Project" p
316
+ WHERE
317
+ p."id" = 'project1'
318
+ )
319
+ )
320
+ ),
321
+ ARRAY ['build1-for-domain2','project1-domain2'],
322
+ 'Test Case 4.2: Should return the latest build for project1 domain with the updated domain in domains array.'
323
+ );
324
+
325
+ --------------------------------------------------------------------------------
326
+ -- Test Case 5: Register Custom Domains and Verify Latest Build for a Custom Domain
327
+ --------------------------------------------------------------------------------
328
+ -- Insert custom domains
329
+ INSERT INTO
330
+ "public"."Domain" (
331
+ "id",
332
+ "domain",
333
+ "createdAt",
334
+ "status",
335
+ "updatedAt"
336
+ )
337
+ VALUES
338
+ (
339
+ 'project-1-custom-domain-1',
340
+ '517cce32-9af3-project-1-custom-domain-1.com',
341
+ '2023-01-01 00:00:00+00',
342
+ 'INITIALIZING',
343
+ '2023-01-01 00:00:00+00'
344
+ ),
345
+ (
346
+ 'project-1-custom-domain-2',
347
+ '517cce32-9af3-project-1-custom-domain-2.com',
348
+ '2023-01-01 00:00:00+00',
349
+ 'INITIALIZING',
350
+ '2023-01-01 00:00:00+00'
351
+ );
352
+
353
+ -- Establish relationships between project1 and custom domains
354
+ INSERT INTO
355
+ "public"."ProjectDomain" (
356
+ "projectId",
357
+ "domainId",
358
+ "createdAt",
359
+ "txtRecord",
360
+ "cname"
361
+ )
362
+ VALUES
363
+ (
364
+ 'project1',
365
+ 'project-1-custom-domain-1',
366
+ '2023-01-01 00:00:00+00',
367
+ 'txtRecord1',
368
+ 'cname1'
369
+ ),
370
+ (
371
+ 'project1',
372
+ 'project-1-custom-domain-2',
373
+ '2023-01-01 00:00:00+00',
374
+ 'txtRecord2',
375
+ 'cname2'
376
+ );
377
+
378
+ -- Insert a build associated with a custom domain
379
+ INSERT INTO
380
+ "public"."Build" (
381
+ "id",
382
+ "createdAt",
383
+ "pages",
384
+ "projectId",
385
+ "deployment",
386
+ "updatedAt",
387
+ "publishStatus"
388
+ )
389
+ VALUES
390
+ (
391
+ 'build1-for-custom-domain-1',
392
+ '2023-01-02 00:00:00+00',
393
+ 'home',
394
+ 'project1',
395
+ '{"domains": ["some-other-domain.com", "517cce32-9af3-project-1-custom-domain-1.com"]}' :: text,
396
+ '2023-01-02 00:00:00+00',
397
+ 'PUBLISHED'
398
+ );
399
+
400
+ -- Verify that the latest build reflects the custom domain association
401
+ SELECT
402
+ is (
403
+ (
404
+ SELECT
405
+ ARRAY ["buildId", "domain"]
406
+ FROM
407
+ "public"."latestBuildVirtual"(
408
+ (
409
+ SELECT
410
+ (p.*) :: "Project"
411
+ FROM
412
+ "public"."Project" p
413
+ WHERE
414
+ p."id" = 'project1'
415
+ )
416
+ )
417
+ ),
418
+ ARRAY ['build1-for-custom-domain-1','517cce32-9af3-project-1-custom-domain-1.com'],
419
+ 'Test Case 5.1: Should return the latest build for project1 with a registered custom domain in domains array.'
420
+ );
421
+
422
+ -- Ensure the latest project domain build has not changed
423
+ -- The difference between latestProjectDomainBuildVirtual and latestBuildVirtual is that the first returns data only for the project domain
424
+ SELECT
425
+ is (
426
+ (
427
+ SELECT
428
+ ARRAY ["buildId", "domain"]
429
+ FROM
430
+ "public"."latestProjectDomainBuildVirtual"(
431
+ (
432
+ SELECT
433
+ (p.*) :: "Project"
434
+ FROM
435
+ "public"."Project" p
436
+ WHERE
437
+ p."id" = 'project1'
438
+ )
439
+ )
440
+ ),
441
+ ARRAY ['build1-for-domain2','project1-domain2'],
442
+ 'Test Case 5.2: Should return the latest build for project1 domain and not affected by custom domains'
443
+ );
444
+
445
+ --------------------------------------------------------------------------------
446
+ -- Test Case 6: Publish a Preview Domain and Verify Latest Build Retrieval
447
+ --------------------------------------------------------------------------------
448
+ -- Insert a build for the preview domain using the new deployment format
449
+ INSERT INTO
450
+ "public"."Build" (
451
+ "id",
452
+ "createdAt",
453
+ "pages",
454
+ "projectId",
455
+ "deployment",
456
+ "updatedAt",
457
+ "publishStatus"
458
+ )
459
+ VALUES
460
+ (
461
+ 'build1-for-domain2-new',
462
+ '2023-01-03 00:00:00+00',
463
+ 'home',
464
+ 'project1',
465
+ '{"domains": ["517cce32-9af3-project-1-custom-domain-1.com", "project1-domain2"]}' :: text,
466
+ '2023-01-03 00:00:00+00',
467
+ 'PUBLISHED'
468
+ );
469
+
470
+ -- Verify that the latest build reflects the preview domain
471
+ SELECT
472
+ is (
473
+ (
474
+ SELECT
475
+ ARRAY ["buildId", "domain"]
476
+ FROM
477
+ "public"."latestBuildVirtual"(
478
+ (
479
+ SELECT
480
+ (p.*) :: "Project"
481
+ FROM
482
+ "public"."Project" p
483
+ WHERE
484
+ p."id" = 'project1'
485
+ )
486
+ )
487
+ ),
488
+ ARRAY ['build1-for-domain2-new', 'project1-domain2'],
489
+ 'Test Case 6.1: Should return the latest build for project1 with the preview domain in domains array.'
490
+ );
491
+
492
+ SELECT
493
+ is (
494
+ (
495
+ SELECT
496
+ ARRAY ["buildId", "domain"]
497
+ FROM
498
+ "public"."latestProjectDomainBuildVirtual"(
499
+ (
500
+ SELECT
501
+ (p.*) :: "Project"
502
+ FROM
503
+ "public"."Project" p
504
+ WHERE
505
+ p."id" = 'project1'
506
+ )
507
+ )
508
+ ),
509
+ ARRAY ['build1-for-domain2-new', 'project1-domain2'],
510
+ 'Test Case 6.2: Should return the latest build for project1 with the preview domain in domains array.'
511
+ );
512
+
513
+ --------------------------------------------------------------------------------
514
+ -- Test Case 7: Publish a New Build for a Custom Domain, Delete the Custom Domain, and Verify Latest Build Update
515
+ --------------------------------------------------------------------------------
516
+ -- Insert a new build for the custom domain
517
+ INSERT INTO
518
+ "public"."Build" (
519
+ "id",
520
+ "createdAt",
521
+ "pages",
522
+ "projectId",
523
+ "deployment",
524
+ "updatedAt",
525
+ "publishStatus"
526
+ )
527
+ VALUES
528
+ (
529
+ 'build1-for-custom-domain-1-new',
530
+ '2023-01-04 00:00:00+00',
531
+ 'home',
532
+ 'project1',
533
+ '{"domains": ["some-other-domain.com", "517cce32-9af3-project-1-custom-domain-1.com"]}' :: text,
534
+ '2023-01-04 00:00:00+00',
535
+ 'PUBLISHED'
536
+ );
537
+
538
+ -- Verify that the latest build reflects the newly published build for the custom domain
539
+ SELECT
540
+ is (
541
+ (
542
+ SELECT
543
+ "buildId"
544
+ FROM
545
+ "public"."latestBuildVirtual"(
546
+ (
547
+ SELECT
548
+ (p.*) :: "Project"
549
+ FROM
550
+ "public"."Project" p
551
+ WHERE
552
+ p."id" = 'project1'
553
+ )
554
+ )
555
+ ),
556
+ 'build1-for-custom-domain-1-new',
557
+ 'Test Case 7a: Should return the latest build after publishing a new build for a custom domain.'
558
+ );
559
+
560
+ -- Delete the custom domain association
561
+ DELETE FROM
562
+ "public"."ProjectDomain"
563
+ WHERE
564
+ "projectId" = 'project1'
565
+ AND "domainId" = 'project-1-custom-domain-1';
566
+
567
+ -- Verify that the latest build reverts to the previous latest build after deletion
568
+ SELECT
569
+ is (
570
+ (
571
+ SELECT
572
+ "buildId"
573
+ FROM
574
+ "public"."latestBuildVirtual"(
575
+ (
576
+ SELECT
577
+ (p.*) :: "Project"
578
+ FROM
579
+ "public"."Project" p
580
+ WHERE
581
+ p."id" = 'project1'
582
+ )
583
+ )
584
+ ),
585
+ 'build1-for-domain2-new',
586
+ 'Test Case 7b: Should return the latest build after deleting the custom domain, reverting to the previous latest build.'
587
+ );
588
+
589
+ --------------------------------------------------------------------------------
590
+ -- Test Case 8: Publish a New Build for a Custom Domain, Move the Custom Domain, and Verify Latest Build Update
591
+ --------------------------------------------------------------------------------
592
+ -- Re-establish the custom domain association to revert Test Case 7
593
+ INSERT INTO
594
+ "public"."ProjectDomain" (
595
+ "projectId",
596
+ "domainId",
597
+ "createdAt",
598
+ "txtRecord",
599
+ "cname"
600
+ )
601
+ VALUES
602
+ (
603
+ 'project1',
604
+ 'project-1-custom-domain-1',
605
+ '2023-01-01 00:00:00+00',
606
+ 'txtRecord1',
607
+ 'cname1'
608
+ );
609
+
610
+ -- Verify that the latest build is updated after re-establishing the custom domain
611
+ SELECT
612
+ is (
613
+ (
614
+ SELECT
615
+ "buildId"
616
+ FROM
617
+ "public"."latestBuildVirtual"(
618
+ (
619
+ SELECT
620
+ (p.*) :: "Project"
621
+ FROM
622
+ "public"."Project" p
623
+ WHERE
624
+ p."id" = 'project1'
625
+ )
626
+ )
627
+ ),
628
+ 'build1-for-custom-domain-1-new',
629
+ 'Test Case 8a: Should return the latest build after re-publishing a new build for a custom domain.'
630
+ );
631
+
632
+ -- Move the custom domain association from project1 to project2
633
+ UPDATE
634
+ "public"."ProjectDomain"
635
+ SET
636
+ "projectId" = 'project2'
637
+ WHERE
638
+ "projectId" = 'project1'
639
+ AND "domainId" = 'project-1-custom-domain-1';
640
+
641
+ -- Verify that the latest build reverts to the previous latest build after moving the custom domain
642
+ SELECT
643
+ is (
644
+ (
645
+ SELECT
646
+ "buildId"
647
+ FROM
648
+ "public"."latestBuildVirtual"(
649
+ (
650
+ SELECT
651
+ (p.*) :: "Project"
652
+ FROM
653
+ "public"."Project" p
654
+ WHERE
655
+ p."id" = 'project1'
656
+ )
657
+ )
658
+ ),
659
+ 'build1-for-domain2-new',
660
+ 'Test Case 8b: Should return the latest build after moving the custom domain, reverting to the previous latest build.'
661
+ );
662
+
663
+ --------------------------------------------------------------------------------
664
+ -- Test Case 9: Verify updatedAt Field is Returned (Selection is Still by createdAt)
665
+ --------------------------------------------------------------------------------
666
+ -- Insert builds with different createdAt and updatedAt
667
+ -- NOTE: "Latest build" is determined by createdAt (when published), not updatedAt
668
+ INSERT INTO
669
+ "public"."Build" (
670
+ "id",
671
+ "createdAt",
672
+ "pages",
673
+ "projectId",
674
+ "deployment",
675
+ "updatedAt",
676
+ "publishStatus"
677
+ )
678
+ VALUES
679
+ -- Older createdAt but newer updatedAt
680
+ (
681
+ 'build-updated-recently',
682
+ '2023-01-01 00:00:00+00',
683
+ 'home',
684
+ 'project2',
685
+ '{"domains": ["517cce32-9af3-project2-domain1"]}' :: text,
686
+ '2024-01-01 00:00:00+00',
687
+ 'PUBLISHED'
688
+ ),
689
+ -- Newer createdAt but older updatedAt - SHOULD be selected as "latest"
690
+ (
691
+ 'build-created-recently',
692
+ '2023-06-01 00:00:00+00',
693
+ 'home',
694
+ 'project2',
695
+ '{"domains": ["517cce32-9af3-project2-domain1"]}' :: text,
696
+ '2023-01-15 00:00:00+00',
697
+ 'PUBLISHED'
698
+ );
699
+
700
+ -- Verify that the build with newest createdAt is selected (not newest updatedAt)
701
+ SELECT
702
+ is (
703
+ (
704
+ SELECT
705
+ "buildId"
706
+ FROM
707
+ "public"."latestBuildVirtual"(
708
+ (
709
+ SELECT
710
+ (p.*) :: "Project"
711
+ FROM
712
+ "public"."Project" p
713
+ WHERE
714
+ p."id" = 'project2'
715
+ )
716
+ )
717
+ ),
718
+ 'build-created-recently',
719
+ 'Test Case 9.1: Should select build with newest createdAt (selection is by createdAt, not updatedAt).'
720
+ );
721
+
722
+ -- Verify that updatedAt field is returned (even though it is not the newest)
723
+ SELECT
724
+ is (
725
+ (
726
+ SELECT
727
+ "updatedAt"
728
+ FROM
729
+ "public"."latestBuildVirtual"(
730
+ (
731
+ SELECT
732
+ (p.*) :: "Project"
733
+ FROM
734
+ "public"."Project" p
735
+ WHERE
736
+ p."id" = 'project2'
737
+ )
738
+ )
739
+ ),
740
+ '2023-01-15 00:00:00+00' :: timestamp with time zone,
741
+ 'Test Case 9.2: updatedAt field from the selected build should be returned in latestBuildVirtual result.'
742
+ );
743
+
744
+ SELECT
745
+ is (
746
+ (
747
+ SELECT
748
+ "updatedAt"
749
+ FROM
750
+ "public"."latestProjectDomainBuildVirtual"(
751
+ (
752
+ SELECT
753
+ (p.*) :: "Project"
754
+ FROM
755
+ "public"."Project" p
756
+ WHERE
757
+ p."id" = 'project2'
758
+ )
759
+ )
760
+ ),
761
+ '2023-01-15 00:00:00+00' :: timestamp with time zone,
762
+ 'Test Case 9.3: updatedAt field from the selected build should be returned in latestProjectDomainBuildVirtual result.'
763
+ );
764
+
765
+ --------------------------------------------------------------------------------
766
+ -- Test Case 10: Verify All Columns Are Returned in Correct Order
767
+ --------------------------------------------------------------------------------
768
+ -- Check that all 7 columns are present in the result
769
+ SELECT
770
+ ok(
771
+ (
772
+ SELECT
773
+ COUNT(*) = 7
774
+ FROM
775
+ information_schema.columns
776
+ WHERE
777
+ table_name = 'latestBuildVirtual'
778
+ ),
779
+ 'Test Case 10: latestBuildVirtual should have exactly 7 columns (buildId, projectId, domainsVirtualId, domain, createdAt, publishStatus, updatedAt).'
780
+ );
781
+
782
+ -- Verify column names match expected structure
783
+ SELECT
784
+ bag_eq(
785
+ $$
786
+ SELECT
787
+ column_name :: text
788
+ FROM
789
+ information_schema.columns
790
+ WHERE
791
+ table_name = 'latestBuildVirtual' $$,
792
+ $$
793
+ VALUES
794
+ ('buildId'),
795
+ ('projectId'),
796
+ ('domainsVirtualId'),
797
+ ('domain'),
798
+ ('createdAt'),
799
+ ('publishStatus'),
800
+ ('updatedAt') $$,
801
+ 'Test Case 10.1: All expected columns should be present in latestBuildVirtual table.'
802
+ );
803
+
804
+ -- Finalize the tests
805
+ SELECT
806
+ finish();
807
+
808
+ ROLLBACK;