Skip to content

Commit

Permalink
Add tilde tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mtibben committed Mar 7, 2022
1 parent a382f92 commit 81fed19
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions tilde_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//go:build linux
// +build linux

package keyring

import "testing"

func TestExpandTilde(t *testing.T) {
t.Setenv("HOME", "/home/testing")
actual, err := ExpandTilde("~/one/two")
if err != nil {
t.Fatal(err)
}
expected := "/home/testing/one/two"
if actual != expected {
t.Fatalf("%s != %s", expected, actual)
}
}

func TestExpandTildeWithoutSlash(t *testing.T) {
t.Setenv("HOME", "/home/testing")
actual, err := ExpandTilde("~one/two")
if err != nil {
t.Fatal(err)
}
expected := "~one/two"
if actual != expected {
t.Fatalf("%s != %s", expected, actual)
}
}
func TestExpandTildeWithoutLeadingTilde(t *testing.T) {
t.Setenv("HOME", "/home/testing")
actual, err := ExpandTilde("one/two~")
if err != nil {
t.Fatal(err)
}
expected := "one/two~"
if actual != expected {
t.Fatalf("%s != %s", expected, actual)
}
}

0 comments on commit 81fed19

Please sign in to comment.