Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test imports exactly #126

Merged
merged 1 commit into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions tests/common/import.nu
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
export def "assert imports" [
module: string, submodule: string, expected: list<string>, --prefix: string = "gm "
module: string, submodule: string, expected: list<string>
] {
let src = $"
let before = ^$nu.current-exe --no-config-file --commands "
scope commands | get name
| to nuon
" | from nuon
let after = ^$nu.current-exe --no-config-file --commands $"
use ./src/($module)/ ($submodule) *
scope commands | get name | where \($it | str starts-with '($prefix)'\) | to nuon
"
scope commands | get name
| to nuon" | from nuon

let actual = ^$nu.current-exe --no-config-file --commands $src | from nuon
assert equal $actual $expected
let imported = $after | where $it not-in $before

assert equal $imported $expected
}
1 change: 1 addition & 0 deletions tests/gm.nu
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ export def store-cleaning [] {

export def user-import [] {
assert imports "nu-git-manager" "" [
"gm",
"gm clean",
"gm clone",
"gm list",
Expand Down
5 changes: 1 addition & 4 deletions tests/sugar/mod.nu
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ use ../common/import.nu ["assert imports"]
const MODULE = "nu-git-manager-sugar"

export module imports {
export def main [] {
assert imports $MODULE "" []
}

export def extra [] {
assert imports $MODULE "extra" [ "gm report" ]
}
Expand All @@ -26,6 +22,7 @@ export module imports {
"gm repo ls",
"gm repo remote list",
"gm repo switch",
"prompt setup",
]
}

Expand Down