Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
Signed-off-by: Paulo Gomes <[email protected]>
  • Loading branch information
pjbgf committed Jan 27, 2025
1 parent 8550cd6 commit 761e825
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
1 change: 0 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ name: Test

on:
push:
branches: [ "master", "main" ]
pull_request:

permissions: {}
Expand Down
23 changes: 14 additions & 9 deletions test/basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -493,25 +493,30 @@ func TestRename(t *testing.T) {
name: "file rename",
before: func(t *testing.T, fs billy.Filesystem) {
root := fsRoot(fs)
_, err := fs.Create(fs.Join(root, "foo"))
f, err := fs.Create(fs.Join(root, "foo"))
require.NoError(t, err)
require.NoError(t, f.Close())
},
from: "foo",
to: "bar",
wantFiles: []string{"/bar"},
wantFiles: []string{filepath.FromSlash("/bar")},
},
{
name: "dir rename",
before: func(t *testing.T, fs billy.Filesystem) {
root := fsRoot(fs)
_, err := fs.Create(fs.Join(root, "foo", "bar1"))
f, err := fs.Create(fs.Join(root, "foo", "bar1"))
require.NoError(t, err)
_, err = fs.Create(fs.Join(root, "foo", "bar2"))
require.NoError(t, f.Close())
f, err = fs.Create(fs.Join(root, "foo", "bar2"))
require.NoError(t, err)
require.NoError(t, f.Close())
},
from: "foo",
to: "bar",
wantFiles: []string{"/bar/bar1", "/bar/bar2"},
from: "foo",
to: "bar",
wantFiles: []string{
filepath.FromSlash("/bar/bar1"),
filepath.FromSlash("/bar/bar2")},
},
}

Expand Down Expand Up @@ -541,7 +546,7 @@ func TestRename(t *testing.T) {
return nil
}

if root != "/" {
if filepath.Dir(root) == "" {
path = strings.TrimPrefix(path, root)
}
if !slices.Contains(tc.wantFiles, path) {
Expand All @@ -567,7 +572,7 @@ func fsRoot(fs billy.Filesystem) string {
if reflect.TypeOf(fs) == reflect.TypeOf(&osfs.BoundOS{}) {
return fs.Root()
}
return "/"
return string(filepath.Separator)
}

func TestOpenAndWrite(t *testing.T) {
Expand Down

0 comments on commit 761e825

Please sign in to comment.