Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions bindings/dotnet/OpenDAL.Tests/Behavior/ListBehaviorTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
{
Expand All @@ -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]
Expand Down
10 changes: 8 additions & 2 deletions bindings/go/tests/behavior_tests/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion bindings/go/tests/behavior_tests/read_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down
2 changes: 1 addition & 1 deletion bindings/go/tests/behavior_tests/stat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down
Loading