-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Here we move tilde expansion to be as late as possible. This prevents cli actions like `nats context edit` from rewriting the value of the path to file, and instead only expanding the tilde when needed.
- Loading branch information
Showing
5 changed files
with
41 additions
and
39 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
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
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,23 @@ | ||
package natscontext | ||
|
||
import "testing" | ||
|
||
func TestContext(t *testing.T) { | ||
// Do nothing if the string does not start with ~ | ||
t1 := expandHomedir("foo") | ||
if t1 != "foo" { | ||
t.Fatalf("failed to expand home directory for string 'foo': %s", t1) | ||
} | ||
|
||
// Expand ~ to HOMEDIR if string starts with ~ | ||
t2 := expandHomedir("~/foo") | ||
if t2 == "~/foo" { | ||
t.Fatalf("failed to expand home directory for string 'foo': %s", t2) | ||
} | ||
|
||
// Do nothing if there is a ~ but it is not the first character of the string | ||
t3 := expandHomedir("/~/foo") | ||
if t3 != "/~/foo" { | ||
t.Fatalf("failed to expand home directory for string 'foo': %s", t3) | ||
} | ||
} |