Skip to content
This repository has been archived by the owner on Feb 17, 2024. It is now read-only.

Commit

Permalink
internal/print/human: fix Path tests
Browse files Browse the repository at this point in the history
Signed-off-by: Achille Roussel <[email protected]>
  • Loading branch information
achille-roussel committed May 29, 2023
1 parent 170070d commit c7b21b8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ flatbuffers: go.mod $(format.src.go)
$(GO) build ./format/...

test: flatbuffers testdata
$(GO) test -v ./...
$(GO) test ./...

testdata: $(testdata.go.wasm)

Expand Down
16 changes: 10 additions & 6 deletions internal/print/human/path_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ func TestPath(t *testing.T) {

tests := []struct {
in string
out Path
out string
}{
{in: ".", out: "."},
{in: separator, out: Path(separator)},
{in: filepath.Join(".", "hello", "world"), out: Path(filepath.Join(".", "hello", "world"))},
{in: filepath.Join("~", "hello", "world"), out: Path(filepath.Join(os.Getenv("HOME"), "hello", "world"))},
{in: separator, out: separator},
{in: filepath.Join(".", "hello", "world"), out: filepath.Join(".", "hello", "world")},
{in: filepath.Join("~", "hello", "world"), out: filepath.Join(os.Getenv("HOME"), "hello", "world")},
}

for _, test := range tests {
Expand All @@ -25,8 +25,12 @@ func TestPath(t *testing.T) {

if err := path.UnmarshalText([]byte(test.in)); err != nil {
t.Error(err)
} else if path != test.out {
t.Errorf("path mismatch: %q != %q", path, test.out)
}
resolved, err := path.Resolve()
if err != nil {
t.Error(err)
} else if resolved != test.out {
t.Errorf("path mismatch: %q != %q", resolved, test.out)
}
})
}
Expand Down

0 comments on commit c7b21b8

Please sign in to comment.