diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a31d346..fa2b93d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,9 +1,6 @@ name: CI on: - push: - branches: - - main pull_request: jobs: diff --git a/tests/test_env.nim b/tests/test_env.nim new file mode 100644 index 0000000..b70dc95 --- /dev/null +++ b/tests/test_env.nim @@ -0,0 +1,34 @@ +discard """ + cmd: "nim c --skipUserCfg $file" +""" + +import unittest +import std/os +import std/osproc +import std/strutils +import icp_network + +const + ICP_PATH = "icp" + ENV_SAMPLE_DIR = "/application/examples/env_sample" + +suite "Environment variable canister tests": + test "local environment is returned by the canister": + ensureIcpNetworkStarted(ENV_SAMPLE_DIR) + + let originalDir = getCurrentDir() + try: + setCurrentDir(ENV_SAMPLE_DIR) + + let (deployOutput, deployExitCode) = execCmdEx(ICP_PATH & " deploy -y") + check deployExitCode == 0 + if deployExitCode == 0: + let (callOutput, callExitCode) = execCmdEx( + ICP_PATH & " canister call backend env '()'" + ) + check callExitCode == 0 + check callOutput.strip() == "(\"local\")" + else: + echo deployOutput + finally: + setCurrentDir(originalDir)