aboutsummaryrefslogtreecommitdiff
path: root/lib/memfs/memfs_test.go
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2023-10-29 00:46:53 +0700
committerShulhan <ms@kilabit.info>2023-10-29 00:46:53 +0700
commit72e51cb4606155d9a3ecc9777aeb41579045f868 (patch)
treee0a36218e18a6ebc59beec73844c27fde4dee5d6 /lib/memfs/memfs_test.go
parentcea29b1890e2e03c4744d50c3c9d6d3dc4535bdf (diff)
downloadpakakeh.go-72e51cb4606155d9a3ecc9777aeb41579045f868.tar.xz
lib/memfs: add method Child to Node
The Child method return the child node based on its node.
Diffstat (limited to 'lib/memfs/memfs_test.go')
-rw-r--r--lib/memfs/memfs_test.go33
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/memfs/memfs_test.go b/lib/memfs/memfs_test.go
index f2ac87f1..6d8dbadc 100644
--- a/lib/memfs/memfs_test.go
+++ b/lib/memfs/memfs_test.go
@@ -437,6 +437,39 @@ func TestMemFS_MarshalJSON(t *testing.T) {
}
}
+func TestMemFS_RemoveChild(t *testing.T) {
+ var (
+ opts = &Options{
+ Root: `testdata`,
+ MaxFileSize: -1,
+ }
+ mfs *MemFS
+ err error
+ )
+
+ mfs, err = New(opts)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ var child = mfs.Root.Child(`plain`)
+ if child == nil {
+ t.Fatal(`Expecting child "plain", got nil`)
+ }
+
+ var nodeRemoved = mfs.RemoveChild(mfs.Root, child)
+ if nodeRemoved == nil {
+ t.Fatal(`Expecting child "plain", got nil`)
+ }
+
+ test.Assert(t, `RemoveChild`, child, nodeRemoved)
+
+ child = mfs.Root.Child(`plain`)
+ if child != nil {
+ t.Fatalf(`Expecting child "plain" has been removed, got %v`, child)
+ }
+}
+
func TestMemFS_isIncluded(t *testing.T) {
cases := []struct {
desc string