Skip to content

Commit

Permalink
chore: add test case for installing with not listed extension (#697)
Browse files Browse the repository at this point in the history
  • Loading branch information
halajohn authored Feb 10, 2025
1 parent 1345d58 commit 1214a30
Show file tree
Hide file tree
Showing 7 changed files with 107 additions and 4 deletions.
1 change: 1 addition & 0 deletions tests/ten_manager/install_all/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#
group("install_all") {
deps = [
"extension_not_listed_in_app",
"install_a_before_install_all",
"install_all_fail_with_local_unsupported_pkg",
"install_all_in_local_file_system",
Expand Down
22 changes: 22 additions & 0 deletions tests/ten_manager/install_all/extension_not_listed_in_app/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#
# Copyright © 2025 Agora
# This file is part of TEN Framework, an open source project.
# Licensed under the Apache License, Version 2.0, with certain conditions.
# Refer to the "LICENSE" file in the root directory for more information.
#
import("//build/ten_runtime/feature/test.gni")

ten_package_test_prepare_auxiliary_resources("extension_not_listed_in_app") {
resources = [
"//.gnfiles/build/scripts/cmd_exec.py=>common/cmd_exec.py",
"__init__.py",
"test_app/manifest.json",
"test_app/ten_packages/extension/ext_not_listed/manifest.json",
"test_case.py",
]

deps = [
"//core/src/ten_manager",
"//tests/local_registry",
]
}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"type": "app",
"name": "test_app",
"version": "1.0.0",
"dependencies": [
{
"type": "extension",
"name": "ext_b",
"version": "1.0.0"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"type": "extension",
"name": "ext_not_listed",
"version": "1.0.0",
"dependencies": [
{
"type": "extension",
"name": "ext_not_existed",
"version": "10000.0.0"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#
# Copyright © 2025 Agora
# This file is part of TEN Framework, an open source project.
# Licensed under the Apache License, Version 2.0, with certain conditions.
# Refer to the "LICENSE" file in the root directory for more information.
#
import os
import sys
from .common import cmd_exec


def get_installed_extensions_count(app_dir: str):
extension_dir = os.path.join(app_dir, "ten_packages/extension/")
extensions = os.listdir(extension_dir)

return len(extensions)


def test_tman_dependency_resolve():
base_path = os.path.dirname(os.path.abspath(__file__))
root_dir = os.path.join(base_path, "../../../../")

if sys.platform == "win32":
os.environ["PATH"] = (
os.path.join(root_dir, "ten_manager/lib") + ";" + os.getenv("PATH")
)
tman_bin = os.path.join(root_dir, "ten_manager/bin/tman.exe")
else:
tman_bin = os.path.join(root_dir, "ten_manager/bin/tman")

app_dir = os.path.join(base_path, "test_app")

config_file = os.path.join(
root_dir,
"tests/local_registry/config.json",
)

# Execute 'install_all' in the app.
returncode, output_text = cmd_exec.run_cmd_realtime(
[
tman_bin,
f"--config-file={config_file}",
"--yes",
"install",
],
cwd=app_dir,
)
if returncode != 0:
print(output_text)
assert False

assert get_installed_extensions_count(app_dir) == 3


if __name__ == "__main__":
test_tman_dependency_resolve()
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ def test_tman_dependency_resolve():
"tests/local_registry/config.json",
)

# First, install the extension 'ext_1'. All dependencies in the app including
# 'ext_1' will be installed.
# First, install the extension 'ext_1'. All dependencies in the app
# including 'ext_1' will be installed.
returncode, output_text = cmd_exec.run_cmd_realtime(
[
tman_bin,
Expand All @@ -54,8 +54,8 @@ def test_tman_dependency_resolve():

assert get_installed_extensions_count(app_dir) == 3

# Then, execute 'install_all' in the app, while all extensions have been installed
# in the app, so nothing will be installed again.
# Then, execute 'install_all' in the app, while all extensions have been
# installed in the app, so nothing will be installed again.
returncode, output_text = cmd_exec.run_cmd_realtime(
[
tman_bin,
Expand Down

0 comments on commit 1214a30

Please sign in to comment.