diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 3919366..8f3770d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,6 +1,7 @@ # Description: This workflow runs tests for hustcer/deepseek-review. # REF: # - https://github.com/vyadh/nutest/blob/main/.github/workflows/tests.yaml +# - https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/store-information-in-variables#default-environment-variables name: Run Tests diff --git a/tests/test-common.nu b/tests/test-common.nu index 45746ff..a97a570 100644 --- a/tests/test-common.nu +++ b/tests/test-common.nu @@ -1,7 +1,10 @@ use std/assert -use ../nu/common.nu [compare-ver, 'from env', is-installed, has-ref, git-check, compact-record] +use ../nu/common.nu [ + compare-ver, 'from env', is-installed, has-ref, + git-check, compact-record, is-repo, windows?, mac?, +] #[test] def 'compare-ver:v1.0.0 is greater than v0.999.0' [] { @@ -52,6 +55,11 @@ def 'has-ref:git repo should has HEAD ref' [] { assert equal (has-ref 0000) false } +#[test] +def 'is-repo:current dir is a git repo' [] { + assert equal (is-repo) true +} + #[test] def 'git-check:current dir is a git repo' [] { assert equal (git-check (pwd) --check-repo=1) true @@ -62,3 +70,31 @@ def 'compact-record:should work as expected' [] { assert equal ({a: null, b: '', c: 'abc' } | compact-record) { c: 'abc' } assert equal ({a: null, b: 0, c: 1, e: { f: 'g' } } | compact-record) { b: 0, c: 1, e: { f: 'g' } } } + +#[test] +def 'OS check should work as expected' [] { + # `$env.RUNNER_OS` Possible values are Linux, Windows, or macOS in GitHub Actions + match $nu.os-info.name { + 'windows' => { + assert equal (mac?) false + assert equal (windows?) true + if ($env.RUNNER_OS | is-not-empty) { + assert equal $env.RUNNER_OS Windows + } + } + 'macos' => { + assert equal (mac?) true + assert equal (windows?) false + if ($env.RUNNER_OS | is-not-empty) { + assert equal $env.RUNNER_OS macOS + } + } + _ => { + assert equal (mac?) false + assert equal (windows?) false + if ($env.RUNNER_OS | is-not-empty) { + assert equal $env.RUNNER_OS Linux + } + } + } +}