Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions packages/postgrest/supabase/tests/latest-builds-domains.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ SELECT no_plan();
-- Insert a new user into the User table
INSERT INTO "public"."User" ("id", "createdAt", "email", "username")
VALUES
('user1', '2023-01-01 00:00:00+00', '[email protected]', 'user1');
('user1', '2023-01-01 00:00:00+00', 'user1@517cce32-9af3-example.com', 'user1');

-- Insert projects associated with the user
INSERT INTO "public"."Project" ("id", "title", "domain", "userId", "isDeleted", "createdAt")
VALUES
('project1', 'Project One', 'project1-domain1', 'user1', false, '2023-01-01 00:00:00+00'),
('project2', 'Project Two', 'project2-domain1', 'user1', false, '2023-01-01 00:00:00+00');
('project1', 'Project One', '517cce32-9af3-project1-domain1', 'user1', false, '2023-01-01 00:00:00+00'),
('project2', 'Project Two', '517cce32-9af3-project2-domain1', 'user1', false, '2023-01-01 00:00:00+00');

-- Insert custom domains into the Domain table
INSERT INTO "public"."Domain" ("id", "domain", "createdAt", "status", "updatedAt")
VALUES
('project-1-custom-domain-1', 'project-1-custom-domain-1.com', '2023-01-01 00:00:00+00', 'INITIALIZING', '2023-01-01 00:00:00+00'),
('project-1-custom-domain-2', 'project-1-custom-domain-2.com', '2023-01-01 00:00:00+00', 'INITIALIZING', '2023-01-01 00:00:00+00');
('project-1-custom-domain-1', '517cce32-9af3-project-1-custom-domain-1.com', '2023-01-01 00:00:00+00', 'INITIALIZING', '2023-01-01 00:00:00+00'),
('project-1-custom-domain-2', '517cce32-9af3-project-1-custom-domain-2.com', '2023-01-01 00:00:00+00', 'INITIALIZING', '2023-01-01 00:00:00+00');

-- Establish relationships between projects and custom domains
INSERT INTO "public"."ProjectDomain" ("projectId", "domainId", "createdAt", "txtRecord", "cname")
Expand Down Expand Up @@ -76,7 +76,7 @@ VALUES
'2023-01-02 00:00:00+00',
'home',
'project1',
'{"domains": ["some-other-domain.com", "project-1-custom-domain-1.com"]}'::text,
'{"domains": ["some-other-domain.com", "517cce32-9af3-project-1-custom-domain-1.com"]}'::text,
'2023-01-02 00:00:00+00',
'PUBLISHED'
);
Expand Down Expand Up @@ -113,7 +113,7 @@ VALUES
'2024-01-02 00:00:00+00',
'home',
'project1',
'{"domains": ["some-other-domain.com", "project-1-custom-domain-1.com"]}'::text,
'{"domains": ["some-other-domain.com", "517cce32-9af3-project-1-custom-domain-1.com"]}'::text,
'2024-01-02 00:00:00+00',
'PUBLISHED'
);
Expand Down Expand Up @@ -150,7 +150,7 @@ VALUES
'2024-01-03 00:00:00+00',
'home',
'project1',
'{"domains": ["some-other-domain.com", "project-1-custom-domain-2.com"]}'::text,
'{"domains": ["some-other-domain.com", "517cce32-9af3-project-1-custom-domain-2.com"]}'::text,
'2024-01-03 00:00:00+00',
'PUBLISHED'
);
Expand Down Expand Up @@ -187,7 +187,7 @@ VALUES
'2024-01-04 00:00:00+00',
'home',
'project1',
'{"domains": ["some-other-domain.com", "project-1-custom-domain-2.com", "project-1-custom-domain-1.com"]}'::text,
'{"domains": ["some-other-domain.com", "517cce32-9af3-project-1-custom-domain-2.com", "517cce32-9af3-project-1-custom-domain-1.com"]}'::text,
'2024-01-04 00:00:00+00',
'PUBLISHED'
);
Expand Down Expand Up @@ -230,7 +230,7 @@ VALUES
'2025-01-04 00:00:00+00',
'home',
'project2',
'{"domains": ["some-other-domain.com", "project-1-custom-domain-2.com", "project-1-custom-domain-1.com"]}'::text,
'{"domains": ["some-other-domain.com", "517cce32-9af3-project-1-custom-domain-2.com", "517cce32-9af3-project-1-custom-domain-1.com"]}'::text,
'2025-01-04 00:00:00+00',
'PUBLISHED'
);
Expand Down
26 changes: 13 additions & 13 deletions packages/postgrest/supabase/tests/latest-builds-projects.sql
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ VALUES
-- Insert projects associated with the user
INSERT INTO "public"."Project" ("id", "title", "domain", "userId", "isDeleted", "createdAt")
VALUES
('project1', 'Project One', 'project1-domain1', 'user1', false, '2023-01-01 00:00:00+00'),
('project2', 'Project Two', 'project2-domain1', 'user1', false, '2023-01-01 00:00:00+00');
('project1', 'Project One', '517cce32-9af3-project1-domain1', 'user1', false, '2023-01-01 00:00:00+00'),
('project2', 'Project Two', '517cce32-9af3-project2-domain1', 'user1', false, '2023-01-01 00:00:00+00');

-- Insert builds with different deployment formats
INSERT INTO "public"."Build" (
Expand All @@ -36,7 +36,7 @@ VALUES
'2023-01-01 00:00:00+00',
'home',
'project1',
'{"projectDomain": "project1-domain1", "domains": [""]}'::text,
'{"projectDomain": "517cce32-9af3-project1-domain1", "domains": [""]}'::text,
'2023-01-01 00:00:00+00',
'PUBLISHED'
),
Expand All @@ -45,7 +45,7 @@ VALUES
'2022-01-01 00:00:00+00',
'home',
'project1',
'{"projectDomain": "project1-domain1", "domains": [""]}'::text,
'{"projectDomain": "517cce32-9af3-project1-domain1", "domains": [""]}'::text,
'2022-01-01 00:00:00+00',
'PUBLISHED'
),
Expand All @@ -64,7 +64,7 @@ VALUES
'2023-01-02 00:00:00+00',
'home',
'project2',
'{"domains": ["project2-domain1"]}'::text,
'{"domains": ["517cce32-9af3-project2-domain1"]}'::text,
'2023-01-02 00:00:00+00',
'PENDING'
),
Expand All @@ -73,7 +73,7 @@ VALUES
'2022-01-02 00:00:00+00',
'home',
'project2',
'{"domains": ["project2-domain1"]}'::text,
'{"domains": ["517cce32-9af3-project2-domain1"]}'::text,
'2022-01-02 00:00:00+00',
'PENDING'
);
Expand All @@ -92,7 +92,7 @@ SELECT is (
)
)
),
ARRAY['build1', 'project1-domain1'],
ARRAY['build1', '517cce32-9af3-project1-domain1'],
'Test Case 1: Should return the latest build for project1 with domain matching projectDomain.'
);

Expand Down Expand Up @@ -190,8 +190,8 @@ INSERT INTO "public"."Domain" (
"updatedAt"
)
VALUES
('project-1-custom-domain-1', 'project-1-custom-domain-1.com', '2023-01-01 00:00:00+00', 'INITIALIZING', '2023-01-01 00:00:00+00'),
('project-1-custom-domain-2', 'project-1-custom-domain-2.com', '2023-01-01 00:00:00+00', 'INITIALIZING', '2023-01-01 00:00:00+00');
('project-1-custom-domain-1', '517cce32-9af3-project-1-custom-domain-1.com', '2023-01-01 00:00:00+00', 'INITIALIZING', '2023-01-01 00:00:00+00'),
('project-1-custom-domain-2', '517cce32-9af3-project-1-custom-domain-2.com', '2023-01-01 00:00:00+00', 'INITIALIZING', '2023-01-01 00:00:00+00');

-- Establish relationships between project1 and custom domains
INSERT INTO "public"."ProjectDomain" (
Expand Down Expand Up @@ -221,7 +221,7 @@ VALUES
'2023-01-02 00:00:00+00',
'home',
'project1',
'{"domains": ["some-other-domain.com", "project-1-custom-domain-1.com"]}'::text,
'{"domains": ["some-other-domain.com", "517cce32-9af3-project-1-custom-domain-1.com"]}'::text,
'2023-01-02 00:00:00+00',
'PUBLISHED'
);
Expand All @@ -238,7 +238,7 @@ SELECT is (
)
)
),
ARRAY['build1-for-custom-domain-1','project-1-custom-domain-1.com'],
ARRAY['build1-for-custom-domain-1','517cce32-9af3-project-1-custom-domain-1.com'],
'Test Case 5: Should return the latest build for project1 with a registered custom domain in domains array.'
);

Expand All @@ -261,7 +261,7 @@ VALUES
'2023-01-03 00:00:00+00',
'home',
'project1',
'{"domains": ["project-1-custom-domain-1.com", "project1-domain2"]}'::text,
'{"domains": ["517cce32-9af3-project-1-custom-domain-1.com", "project1-domain2"]}'::text,
'2023-01-03 00:00:00+00',
'PUBLISHED'
);
Expand Down Expand Up @@ -301,7 +301,7 @@ VALUES
'2023-01-04 00:00:00+00',
'home',
'project1',
'{"domains": ["some-other-domain.com", "project-1-custom-domain-1.com"]}'::text,
'{"domains": ["some-other-domain.com", "517cce32-9af3-project-1-custom-domain-1.com"]}'::text,
'2023-01-04 00:00:00+00',
'PUBLISHED'
);
Expand Down
18 changes: 9 additions & 9 deletions packages/postgrest/supabase/tests/project-domains.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ SELECT no_plan();
-- We're inserting user_1 as the user for the test projects
INSERT INTO "public"."User" ("id", "createdAt", "email", "username")
VALUES
('user_1', '2023-01-01 00:00:00+00', '[email protected]', 'user1');
('user_1', '2023-01-01 00:00:00+00', 'user1@517cce32-9af3-example.com', 'user1');

-- Insert test projects into the Project table
-- project_1 and project_2 belong to user_1 and are not deleted (isDeleted = false)
INSERT INTO "Project" (id, title, domain, "userId", "isDeleted") VALUES
('project_1', 'Test Project 1', 'testproject1.com', 'user_1', false),
('project_2', 'Test Project 1', 'testproject2.com', 'user_1', false);
('project_1', 'Test Project 1', '517cce32-9af3-testproject1.com', 'user_1', false),
('project_2', 'Test Project 1', '517cce32-9af3-testproject2.com', 'user_1', false);

-- Insert test domains into the Domain table
-- We are inserting two domains: example.com and example.org with different statuses
-- We are inserting two domains: 517cce32-9af3-example.com and 517cce32-9af3-example.org with different statuses
INSERT INTO "Domain" (id, domain, status, "txtRecord") VALUES
('domain_1', 'example.com', 'INITIALIZING', 'txtRecord1'),
('domain_2', 'example.org', 'ACTIVE', 'txtRecord21');
('domain_1', '517cce32-9af3-example.com', 'INITIALIZING', 'txtRecord1'),
('domain_2', '517cce32-9af3-example.org', 'ACTIVE', 'txtRecord21');

-- Insert test data into the ProjectDomain table
-- Mapping domains to projects, project_1 has two domains, project_2 has one domain
Expand All @@ -43,8 +43,8 @@ SELECT results_eq(
$$
SELECT * FROM (
VALUES
('example.com','INITIALIZING'::"DomainStatus",NULL,E'txtRecord1',E'txtRecord1',TRUE), -- Verified domain (TXT records match)
('example.org','ACTIVE'::"DomainStatus",NULL,E'txtRecord21',E'txtRecord22',FALSE) -- Not verified domain (TXT records do not match)
('517cce32-9af3-example.com','INITIALIZING'::"DomainStatus",NULL,E'txtRecord1',E'txtRecord1',TRUE), -- Verified domain (TXT records match)
('517cce32-9af3-example.org','ACTIVE'::"DomainStatus",NULL,E'txtRecord21',E'txtRecord22',FALSE) -- Not verified domain (TXT records do not match)
) AS expected(domain, status, error, "domainTxtRecord", "expectedTxtRecord", verified)
ORDER BY "domain"
$$,
Expand All @@ -63,7 +63,7 @@ SELECT results_eq(
$$
SELECT * FROM (
VALUES
('example.com','INITIALIZING'::"DomainStatus",NULL,E'txtRecord1',E'txtRecord3',FALSE) -- Not verified domain (TXT records do not match)
('517cce32-9af3-example.com','INITIALIZING'::"DomainStatus",NULL,E'txtRecord1',E'txtRecord3',FALSE) -- Not verified domain (TXT records do not match)
) AS expected(domain, status, error, "domainTxtRecord", "expectedTxtRecord", verified)
ORDER BY "domain"
$$,
Expand Down