From 74e028e827261a15121a38121b386ce756eb9fca Mon Sep 17 00:00:00 2001 From: David Wang Date: Tue, 30 Jan 2024 14:00:30 -0800 Subject: [PATCH] SNOW-1011764: Adding integration test for show/drop image repository --- tests/object/test_object.py | 3 ++- tests_integration/test_object.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/tests/object/test_object.py b/tests/object/test_object.py index a05b67a15f..743bad43c4 100644 --- a/tests/object/test_object.py +++ b/tests/object/test_object.py @@ -116,7 +116,8 @@ def test_that_objects_list_is_in_help(command, runner): for obj in SUPPORTED_OBJECTS: if command == "describe" and obj == "image-repository": assert obj not in result.output, f"{obj} should not be in help message" - assert obj in result.output, f"{obj} in help message" + else: + assert obj in result.output, f"{obj} in help message" @pytest.mark.parametrize( diff --git a/tests_integration/test_object.py b/tests_integration/test_object.py index 5c2ee8d7ca..53c63e30c4 100644 --- a/tests_integration/test_object.py +++ b/tests_integration/test_object.py @@ -53,3 +53,31 @@ def test_object_table(runner, test_database, snowflake_session): assert ( len(row_from_cursor(snowflake_session.execute_string(f"show tables")[-1])) == 0 ) + + +@pytest.mark.integration +def test_show_drop_image_repository(runner, test_database, snowflake_session): + repo_name = "TEST_REPO" + + result_create = runner.invoke_with_connection( + ["sql", "-q", f"create image repository {repo_name}"] + ) + assert result_create.exit_code == 0, result_create.output + assert f"Image Repository {repo_name} successfully created" in result_create.output + + result_show = runner.invoke_with_connection( + ["object", "list", "image-repository", "--format", "json"] + ) + curr = snowflake_session.execute_string(f"show image repositories") + expected = row_from_cursor(curr[-1]) + actual = result_show.json + + assert len(actual) == len(expected) + assert actual[0].keys() == expected[0].keys() + assert actual[0]["name"] == expected[0]["name"] + + result_drop = runner.invoke_with_connection( + ["object", "drop", "image-repository", repo_name] + ) + assert result_drop.exit_code == 0, result_drop.output + assert f"{repo_name} successfully dropped" in result_drop.output