-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #206 from mbland/path-lib
lib/path: Fix @go.canonicalize_path bugs, add @go.add_parent_dir_if_relative_path
- Loading branch information
Showing
3 changed files
with
88 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#! /usr/bin/env bats | ||
|
||
load ../environment | ||
|
||
setup() { | ||
test_filter | ||
@go.create_test_go_script \ | ||
'. "$_GO_USE_MODULES" "path"' \ | ||
'declare result' \ | ||
'@go.add_parent_dir_if_relative_path "$@"' \ | ||
'printf "%s\n" "$result"' | ||
} | ||
|
||
teardown() { | ||
@go.remove_test_go_rootdir | ||
} | ||
|
||
@test "$SUITE: converts a relative path to an absolute path based on PWD" { | ||
run "$TEST_GO_SCRIPT" 'result' 'foo' | ||
assert_success "$TEST_GO_ROOTDIR/foo" | ||
} | ||
|
||
@test "$SUITE: adds a parent to a relative path" { | ||
run "$TEST_GO_SCRIPT" --parent 'foo' 'result' 'bar' | ||
assert_success 'foo/bar' | ||
} | ||
|
||
@test "$SUITE: leaves an absolute path unmodified" { | ||
run "$TEST_GO_SCRIPT" --parent 'foo' 'result' '/bar/baz' | ||
assert_success '/bar/baz' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters