Skip to content

Commit

Permalink
change File.String formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
ungerik committed Nov 24, 2023
1 parent f4e3bce commit 3202f2e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion file.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (file File) RawURI() string {
// See RawURI to just get the string value of it.
// String implements the fmt.Stringer interface.
func (file File) String() string {
return fmt.Sprintf("%q (%s)", file.Path(), file.FileSystem().Name())
return fmt.Sprintf("%s: %s", file.FileSystem().Name(), file.Path())
}

// URL of the file
Expand Down
10 changes: 6 additions & 4 deletions file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"path/filepath"
"testing"
"time"

Expand All @@ -12,10 +13,6 @@ import (
"github.com/ungerik/go-fs/fsimpl"
)

func X(t *testing.T) {
t.Log("X")
}

func TestInvalidFile(t *testing.T) {
assert.False(t, InvalidFile.IsDir(), "InvalidFile does not exist")

Expand Down Expand Up @@ -228,3 +225,8 @@ func TestFile_ListDirInfoRecursiveContext(t *testing.T) {
})
}
}

func TestFile_String(t *testing.T) {
path := filepath.Join("dir", "file.ext")
require.Equal(t, "local file system: "+path, File(path).String())
}

0 comments on commit 3202f2e

Please sign in to comment.