diff --git a/server/tests-py/queries/v1/track_table/setup.yaml b/server/tests-py/queries/v1/track_table/setup.yaml index 028a640e9a1..46f7a1b6e49 100644 --- a/server/tests-py/queries/v1/track_table/setup.yaml +++ b/server/tests-py/queries/v1/track_table/setup.yaml @@ -30,14 +30,27 @@ args: age INTEGER NOT NULL ); + INSERT INTO author (name) VALUES ('Author 1'), ('Author 2'); + INSERT INTO article (title, author_id) VALUES + ('Lorem ipsum dolor sit amet', 1), + ('lolcats: an anthology', 2), + ('consectetur adipiscing elit', 1); + INSERT INTO hge_tests.resident (name, age) VALUES ('Resident 1', 23), ('Resident 2', 31); + + CREATE MATERIALIZED VIEW articles AS + SELECT article.title, author.name + FROM article + LEFT JOIN author ON author.id = article.author_id + ; + CREATE OR REPLACE FUNCTION test1() RETURNS SETOF test2 AS $$ SELECT * FROM test2 diff --git a/server/tests-py/queries/v1/track_table/teardown.yaml b/server/tests-py/queries/v1/track_table/teardown.yaml index c9a99c3b3b3..78c2a3aeba9 100644 --- a/server/tests-py/queries/v1/track_table/teardown.yaml +++ b/server/tests-py/queries/v1/track_table/teardown.yaml @@ -4,6 +4,7 @@ args: - type: run_sql args: sql: | + DROP MATERIALIZED VIEW articles; DROP TABLE hge_tests.resident; DROP TABLE article; DROP TABLE author; diff --git a/server/tests-py/queries/v1/track_table/track_untrack_materialized_view.yaml b/server/tests-py/queries/v1/track_table/track_untrack_materialized_view.yaml new file mode 100644 index 00000000000..6a7484487ce --- /dev/null +++ b/server/tests-py/queries/v1/track_table/track_untrack_materialized_view.yaml @@ -0,0 +1,77 @@ +- description: Track materialized view + url: /v1/query + status: 200 + response: + message: success + query: + type: track_table + args: + name: articles + +- description: Track already untracked materialized view + url: /v1/query + status: 400 + response: + path: $.args + error: 'view/table already tracked : "articles"' + code: already-tracked + query: + type: track_table + args: + name: articles + +- description: Select query + url: /v1/query + status: 200 + response: + - title: "Lorem ipsum dolor sit amet" + name: Author 1 + - title: "lolcats: an anthology" + name: Author 2 + - title: "consectetur adipiscing elit" + name: Author 1 + query: + type: select + args: + table: articles + columns: + - title + - name + +- description: Untrack materialized view + url: /v1/query + status: 200 + response: + message: success + query: + type: untrack_table + args: + table: articles + + +- description: Untrack materialized view + url: /v1/query + status: 400 + response: + path: $.args + error: 'view/table already untracked : "articles"' + code: already-untracked + query: + type: untrack_table + args: + table: articles + +- description: Select query error + url: /v1/query + status: 400 + response: + path: $.args.table + error: table "articles" does not exist + code: not-exists + query: + type: select + args: + table: articles + columns: + - title + - name diff --git a/server/tests-py/test_v1_queries.py b/server/tests-py/test_v1_queries.py index dbf0049f43d..7816544d3dd 100644 --- a/server/tests-py/test_v1_queries.py +++ b/server/tests-py/test_v1_queries.py @@ -629,6 +629,10 @@ class TestTrackTables: check_query_f(hge_ctx, self.dir() + '/track_untrack_table.yaml') hge_ctx.may_skip_test_teardown = True + def test_track_untrack_materialized_view(self, hge_ctx): + check_query_f(hge_ctx, self.dir() + '/track_untrack_materialized_view.yaml') + hge_ctx.may_skip_test_teardown = True + def test_track_untrack_table_with_deps(self, hge_ctx): check_query_f(hge_ctx, self.dir() + '/track_untrack_table_deps.yaml') hge_ctx.may_skip_test_teardown = True