From 38f14868b013eaeb28cfba33d5dbf4626e9e4b3f Mon Sep 17 00:00:00 2001 From: Dima Pristupa Date: Wed, 9 Oct 2024 18:27:52 +0300 Subject: [PATCH] E2E, test_new_{root,derivative}(): add --- .../app/cli/inmem/tests/tests/commands/mod.rs | 1 + .../tests/tests/commands/test_new_command.rs | 26 +++++++ .../app/cli/repo-tests/src/commands/mod.rs | 2 + .../src/commands/test_new_command.rs | 68 +++++++++++++++++++ 4 files changed, 97 insertions(+) create mode 100644 src/e2e/app/cli/inmem/tests/tests/commands/test_new_command.rs create mode 100644 src/e2e/app/cli/repo-tests/src/commands/test_new_command.rs diff --git a/src/e2e/app/cli/inmem/tests/tests/commands/mod.rs b/src/e2e/app/cli/inmem/tests/tests/commands/mod.rs index 0d1d5ad2d..4aedec009 100644 --- a/src/e2e/app/cli/inmem/tests/tests/commands/mod.rs +++ b/src/e2e/app/cli/inmem/tests/tests/commands/mod.rs @@ -15,6 +15,7 @@ mod test_ingest_command; mod test_init_command; mod test_inspect_command; mod test_log_command; +mod test_new_command; mod test_rename_command; mod test_repo_alias_command; mod test_sql_command; diff --git a/src/e2e/app/cli/inmem/tests/tests/commands/test_new_command.rs b/src/e2e/app/cli/inmem/tests/tests/commands/test_new_command.rs new file mode 100644 index 000000000..fd38ab3d6 --- /dev/null +++ b/src/e2e/app/cli/inmem/tests/tests/commands/test_new_command.rs @@ -0,0 +1,26 @@ +// Copyright Kamu Data, Inc. and contributors. All rights reserved. +// +// Use of this software is governed by the Business Source License +// included in the LICENSE file. +// +// As of the Change Date specified in that file, in accordance with +// the Business Source License, use of this software will be governed +// by the Apache License, Version 2.0. + +use kamu_cli_e2e_common::prelude::*; + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +kamu_cli_execute_command_e2e_test!( + storage = inmem, + fixture = kamu_cli_e2e_repo_tests::test_new_root, +); + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +kamu_cli_execute_command_e2e_test!( + storage = inmem, + fixture = kamu_cli_e2e_repo_tests::test_new_derivative, +); + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/e2e/app/cli/repo-tests/src/commands/mod.rs b/src/e2e/app/cli/repo-tests/src/commands/mod.rs index 7d6c98fc4..879c2a08e 100644 --- a/src/e2e/app/cli/repo-tests/src/commands/mod.rs +++ b/src/e2e/app/cli/repo-tests/src/commands/mod.rs @@ -15,6 +15,7 @@ mod test_ingest_command; mod test_init_command; mod test_inspect_command; mod test_log_command; +mod test_new_command; mod test_rename_command; mod test_repo_alias_command; mod test_sql_command; @@ -29,6 +30,7 @@ pub use test_ingest_command::*; pub use test_init_command::*; pub use test_inspect_command::*; pub use test_log_command::*; +pub use test_new_command::*; pub use test_rename_command::*; pub use test_repo_alias_command::*; pub use test_sql_command::*; diff --git a/src/e2e/app/cli/repo-tests/src/commands/test_new_command.rs b/src/e2e/app/cli/repo-tests/src/commands/test_new_command.rs new file mode 100644 index 000000000..7d9db6442 --- /dev/null +++ b/src/e2e/app/cli/repo-tests/src/commands/test_new_command.rs @@ -0,0 +1,68 @@ +// Copyright Kamu Data, Inc. and contributors. All rights reserved. +// +// Use of this software is governed by the Business Source License +// included in the LICENSE file. +// +// As of the Change Date specified in that file, in accordance with +// the Business Source License, use of this software will be governed +// by the Apache License, Version 2.0. + +use kamu_cli_puppet::KamuCliPuppet; + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +pub async fn test_new_root(kamu: KamuCliPuppet) { + let assert = kamu + .execute(["new", "--root", "test-dataset"]) + .await + .success(); + + let stderr = std::str::from_utf8(&assert.get_output().stderr).unwrap(); + + assert!( + stderr.contains(indoc::indoc!( + r#" + Written new manifest template to: test-dataset.yaml + Follow directions in the file's comments and use `kamu add test-dataset.yaml` when ready. + "# + )), + "Unexpected output:\n{stderr}", + ); + + // TODO: After solving this issue, add `kamu add` calls and populate with + // data + // + // `kamu new`: generate snapshots that will be immediately ready to be + // added/worked on + // https://github.com/kamu-data/kamu-cli/issues/888 +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +pub async fn test_new_derivative(kamu: KamuCliPuppet) { + let assert = kamu + .execute(["new", "--derivative", "test-dataset"]) + .await + .success(); + + let stderr = std::str::from_utf8(&assert.get_output().stderr).unwrap(); + + assert!( + stderr.contains(indoc::indoc!( + r#" + Written new manifest template to: test-dataset.yaml + Follow directions in the file's comments and use `kamu add test-dataset.yaml` when ready. + "# + )), + "Unexpected output:\n{stderr}", + ); + + // TODO: After solving this issue, add `kamu add` calls and populate with + // data + // + // `kamu new`: generate snapshots that will be immediately ready to be + // added/worked on + // https://github.com/kamu-data/kamu-cli/issues/888 +} + +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////