diff --git a/bindings/go/tests/behavior_tests/list_test.go b/bindings/go/tests/behavior_tests/list_test.go index f4f26acf4c3..1f6a4a36aab 100644 --- a/bindings/go/tests/behavior_tests/list_test.go +++ b/bindings/go/tests/behavior_tests/list_test.go @@ -201,13 +201,21 @@ func testListNestedDir(assert *require.Assertions, op *opendal.Operator, fixture assert.Nil(err) defer obs.Close() var paths []string + var foundParent bool + var foundDir bool for obs.Next() { entry := obs.Entry() paths = append(paths, entry.Path()) - assert.Equal(dir, entry.Path()) + if entry.Path() == parent { + foundParent = true + } else if entry.Path() == dir { + foundDir = true + } } assert.Nil(obs.Error()) - assert.Equal(1, len(paths), "parent should only got 1 entry") + assert.Equal(2, len(paths), "parent should only got 2 entry") + assert.Equal(foundParent, true, "parent should be found in list") + assert.Equal(foundDir, true, "dir should be found in list") obs, err = op.List(dir) assert.Nil(err) @@ -215,7 +223,7 @@ func testListNestedDir(assert *require.Assertions, op *opendal.Operator, fixture paths = nil var foundFile bool var foundDirPath bool - var foundDir bool + foundDir = false for obs.Next() { entry := obs.Entry() paths = append(paths, entry.Path()) diff --git a/bindings/go/tests/behavior_tests/opendal_test.go b/bindings/go/tests/behavior_tests/opendal_test.go index 9368e78979a..8991f971a3e 100644 --- a/bindings/go/tests/behavior_tests/opendal_test.go +++ b/bindings/go/tests/behavior_tests/opendal_test.go @@ -225,8 +225,8 @@ func (f *fixture) Cleanup(assert *require.Assertions) { f.lock.Lock() defer f.lock.Unlock() - for _, path := range f.paths { - assert.Nil(f.op.Delete(path), "delete must succeed: %s", path) + for i := len(f.paths) - 1; i >= 0; i-- { + assert.Nil(f.op.Delete(f.paths[i]), "delete must succeed: %s", f.paths[i]) } } diff --git a/bindings/go/types.go b/bindings/go/types.go index f4b8be049c6..59583a94afd 100644 --- a/bindings/go/types.go +++ b/bindings/go/types.go @@ -287,6 +287,9 @@ func toOpendalBytes(data []byte) opendalBytes { l := len(data) if l > 0 { ptr = &data[0] + } else { + var b byte + ptr = &b } return opendalBytes{ data: ptr,