Skip to content

Commit

Permalink
fix the Windows tests by sanitizing the paths
Browse files Browse the repository at this point in the history
  • Loading branch information
amtoine committed Nov 6, 2023
1 parent 0d15ba1 commit 821d484
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions tests/gm.nu
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std assert

use ../src/nu-git-manager/fs/path.nu ["path sanitize"]
use ../src/nu-git-manager/ *

def run-with-env [code: closure, --prepare-cache] {
Expand Down Expand Up @@ -80,7 +81,9 @@ export def clone-full-repo [] {
run-with-env --prepare-cache {
gm clone https://github.com/amtoine/nu-git-manager

let repo = $env.GIT_REPOS_HOME | path join "github.com/amtoine/nu-git-manager"
let repo = (
$env.GIT_REPOS_HOME | path join "github.com/amtoine/nu-git-manager" | path sanitize
)

let actual = git -C $repo rev-list HEAD | lines | last
let expected = "2ed2d875d80505d78423328c6b2a60522715fcdf"
Expand All @@ -94,7 +97,7 @@ export def clone-bare [] {

let repo = $env.GIT_REPOS_HOME | path join "github.com/amtoine/nu-git-manager"

assert ($repo | path join "HEAD" | path exists)
assert ($repo | path join "HEAD" | path sanitize | path exists)
}
}

Expand All @@ -103,7 +106,9 @@ export def clone-set-remote [] {
let url = "https://github.com/amtoine/nu-git-manager"
gm clone $url --remote test-remote-name --fetch https --push ssh

let repo = $env.GIT_REPOS_HOME | path join "github.com/amtoine/nu-git-manager"
let repo = (
$env.GIT_REPOS_HOME | path join "github.com/amtoine/nu-git-manager" | path sanitize
)

let actual = git -C $repo remote --verbose
| lines
Expand All @@ -123,12 +128,12 @@ export def status [] {
run-with-env {
let BASE_STATUS = {
root: {
path: $env.GIT_REPOS_HOME,
path: ($env.GIT_REPOS_HOME | path sanitize),
exists: false
},
missing: null,
cache: {
path: $env.GIT_REPOS_CACHE,
path: ($env.GIT_REPOS_CACHE | path sanitize),
exists: false
},
should_update_cache: false
Expand All @@ -153,11 +158,14 @@ export def status [] {
| update cache.exists true
assert equal $actual $expected

rm ($env.GIT_REPOS_HOME | path join "github.com/amtoine/nu-git-manager") --recursive
let repo = (
$env.GIT_REPOS_HOME | path join "github.com/amtoine/nu-git-manager" | path sanitize
)
rm $repo --recursive

let actual = gm status
let expected = $BASE_STATUS
| update missing [($env.GIT_REPOS_HOME | path join "github.com/amtoine/nu-git-manager")]
| update missing [$repo]
| update root.exists true
| update cache.exists true
| update should_update_cache true
Expand Down

0 comments on commit 821d484

Please sign in to comment.