From 3202f2e60de1a9ad47da7dc3eaa2d1536695c8fb Mon Sep 17 00:00:00 2001 From: Erik Unger Date: Fri, 24 Nov 2023 13:20:30 +0100 Subject: [PATCH] change File.String formatting --- file.go | 2 +- file_test.go | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/file.go b/file.go index 4b10e78..58748a7 100644 --- a/file.go +++ b/file.go @@ -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 diff --git a/file_test.go b/file_test.go index 5c73023..1b8f693 100644 --- a/file_test.go +++ b/file_test.go @@ -4,6 +4,7 @@ import ( "context" "errors" "fmt" + "path/filepath" "testing" "time" @@ -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") @@ -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()) +}