Path: redb-route/tests/redb.Route.Tests.S3/S3DoneFileKeysTests.cs
Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route
Page: https://redbase.app/src/dev-2026-12-06/redb-route/tests/redb.Route.Tests.S3/S3DoneFileKeysTests.cs
----
using redb.Route.Expressions;
using redb.Route.S3;
namespace redb.Route.Tests.S3;
///
/// The file keys of the S3 consumer's doneFileName (findings register row 34 point 5): they read the object
/// key; ${file:name} is the whole key, as it always was. An unknown key fails when the options are validated.
///
public sealed class S3DoneFileKeysTests
{
[Theory]
[InlineData("in/2026/order.csv", "${file:name}.done", "in/2026/order.csv.done")]
[InlineData("in/2026/order.csv", "${file:name.noext}.done", "in/2026/order.done")]
[InlineData("in/2026/order.csv", "${file:parent}/ready-${file:ext}", "in/2026/ready-csv")]
[InlineData("in/2026/order.csv", "${FILE:NAME}.done", "in/2026/order.csv.done")]
[InlineData("in.d/order", "${file:name.noext}-${file:ext}", "in.d/order-")]
[InlineData("order.csv", "[${file:parent}][${file:size}][${file:path}]", "[][][]")]
public void TheKeys_ReadTheObjectKey(string objectKey, string pattern, string expected)
{
FileLanguage.Substitute(pattern, new ObjectKeyFacts(objectKey), StringComparison.OrdinalIgnoreCase).Should().Be(expected);
}
[Fact]
public void AnUnknownKey_FailsValidation()
{
var options = new S3EndpointOptions { AccessKey = "key", SecretKey = "secret", DoneFileName = "${file:nosuch}.done" };
var act = () => options.Validate();
act.Should().Throw()
.WithMessage("doneFileName='${file:nosuch}.done': 'nosuch' is not a file key; the keys are name, *");
}
[Fact]
public void AKnownKey_PassesValidation()
{
var options = new S3EndpointOptions { AccessKey = "key", SecretKey = "secret", DoneFileName = "${FILE:NAME}.done" };
var act = () => options.Validate();
act.Should().NotThrow();
}
}