From 1476bf96a3090c244f47f93538296b2ae674d442 Mon Sep 17 00:00:00 2001 From: Xuanwo Date: Mon, 2 Nov 2026 09:42:35 +0800 Subject: [PATCH 1/2] test(bindings): honor optional current version metadata --- .../dotnet/OpenDAL.Tests/Behavior/ListBehaviorTest.cs | 11 +++++++++-- bindings/go/tests/behavior_tests/list_test.go | 10 ++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/bindings/dotnet/OpenDAL.Tests/Behavior/ListBehaviorTest.cs b/bindings/dotnet/OpenDAL.Tests/Behavior/ListBehaviorTest.cs index f901090ea188..7c5dd91d957e 100644 --- a/bindings/dotnet/OpenDAL.Tests/Behavior/ListBehaviorTest.cs +++ b/bindings/dotnet/OpenDAL.Tests/Behavior/ListBehaviorTest.cs @@ -146,7 +146,7 @@ public void ListBehavior_WithLimit_ReturnsAtMostRequestedSize() } [Fact] - public void ListBehavior_WithVersions_ReportsCurrentVersion() + public void ListBehavior_WithVersions_ReportsVersionMetadata() { if (!Supports(c => c.List && c.ListWithVersions && c.Write)) { @@ -164,7 +164,14 @@ public void ListBehavior_WithVersions_ReportsCurrentVersion() .ToList(); Assert.True(versions.Count >= 2, $"expected at least two versions, got {versions.Count}"); - Assert.Single(versions, e => e.Metadata.IsCurrent == true); + Assert.All(versions, e => Assert.False(string.IsNullOrEmpty(e.Metadata.Version))); + + var currentCount = versions.Count(e => e.Metadata.IsCurrent == true); + Assert.InRange(currentCount, 0, 1); + if (versions.All(e => e.Metadata.IsCurrent.HasValue)) + { + Assert.Equal(1, currentCount); + } } [Fact] diff --git a/bindings/go/tests/behavior_tests/list_test.go b/bindings/go/tests/behavior_tests/list_test.go index 3044129db31a..d5dc780f4167 100644 --- a/bindings/go/tests/behavior_tests/list_test.go +++ b/bindings/go/tests/behavior_tests/list_test.go @@ -447,6 +447,7 @@ func testListWithVersions(assert *require.Assertions, op *opendal.Operator, fixt var count int var currentCount int + allCurrentStatesKnown := true for obs.Next() { entry := obs.Entry() if entry.Path() == path { @@ -455,14 +456,19 @@ func testListWithVersions(assert *require.Assertions, op *opendal.Operator, fixt version, ok := meta.Version() assert.True(ok, "version metadata must be present for list with versions") assert.NotEmpty(version, "each version entry must have a version ID") - if curr, ok := meta.IsCurrent(); ok && curr { + curr, known := meta.IsCurrent() + allCurrentStatesKnown = allCurrentStatesKnown && known + if known && curr { currentCount++ } } } assert.Nil(obs.Error()) assert.GreaterOrEqual(count, 2, "list with versions must return at least 2 entries for the same path") - assert.Equal(1, currentCount, "exactly one version entry should be current") + assert.LessOrEqual(currentCount, 1, "at most one version entry should be current") + if allCurrentStatesKnown { + assert.Equal(1, currentCount, "exactly one version entry should be current when all states are known") + } } func testListWithDeleted(assert *require.Assertions, op *opendal.Operator, fixture *fixture) { From 2b36172af9762170c2c16ffef11e88ee45641aa1 Mon Sep 17 00:00:00 2001 From: Xuanwo Date: Mon, 2 Nov 2026 10:15:11 +0800 Subject: [PATCH 2/2] test(go): use the last-modified boundary for conditional requests --- bindings/go/tests/behavior_tests/read_test.go | 2 +- bindings/go/tests/behavior_tests/stat_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bindings/go/tests/behavior_tests/read_test.go b/bindings/go/tests/behavior_tests/read_test.go index 8419bf2affab..6e4f4c7e51a7 100644 --- a/bindings/go/tests/behavior_tests/read_test.go +++ b/bindings/go/tests/behavior_tests/read_test.go @@ -116,7 +116,7 @@ func testReadWithIfModifiedSince(assert *require.Assertions, op *opendal.Operato assert.Nil(err, "read with if-modified-since before last modified must succeed") assert.Equal(content, bs, "read content") - _, err = op.Read(path, opendal.ReadWithIfModifiedSince(lastModified.Add(time.Second))) + _, err = op.Read(path, opendal.ReadWithIfModifiedSince(lastModified)) assert.NotNil(err) assert.Equal(opendal.CodeConditionNotMatch, assertErrorCode(err)) } diff --git a/bindings/go/tests/behavior_tests/stat_test.go b/bindings/go/tests/behavior_tests/stat_test.go index df7e3f3078f8..73f109809382 100644 --- a/bindings/go/tests/behavior_tests/stat_test.go +++ b/bindings/go/tests/behavior_tests/stat_test.go @@ -348,7 +348,7 @@ func testStatWithIfModifiedSince(assert *require.Assertions, op *opendal.Operato assert.Nil(err, "stat with older if_modified_since must succeed") assert.Equal(lastModified, meta.LastModified()) - _, err = op.Stat(path, opendal.StatWithIfModifiedSince(lastModified.Add(time.Second))) + _, err = op.Stat(path, opendal.StatWithIfModifiedSince(lastModified)) assert.NotNil(err) assert.Equal(opendal.CodeConditionNotMatch, assertErrorCode(err)) }