appendix: 23 Code-Ausschnitte aus dem Houston-Repository
Pin nixpkgs to the revision used by itc.componentware: the channel version ships a latexminted that crashes on Python 3.14, which made every listing fail and sent latexmk into an endless error prompt. Also force nonstopmode/halt-on-error so a broken listing can never loop again.
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
|
||||
/// <summary>
|
||||
/// A bucket without a single object: every lookup answers with a 404 and every listing is empty
|
||||
/// until a test puts something in via <see cref="GiveFolder"/>, <see cref="GiveTopLevelFolders"/>
|
||||
/// or <see cref="GiveObjects"/>.
|
||||
/// </summary>
|
||||
private static IAmazonS3 EmptyBucket()
|
||||
{
|
||||
var s3 = Substitute.For<IAmazonS3>();
|
||||
|
||||
// Objects written during the test become visible to later lookups, just like in a real bucket.
|
||||
var writtenObjects = new Dictionary<string, string?>(StringComparer.Ordinal);
|
||||
|
||||
s3.GetObjectMetadataAsync(Arg.Any<GetObjectMetadataRequest>(), Arg.Any<CancellationToken>())
|
||||
.Returns(call =>
|
||||
{
|
||||
var key = call.Arg<GetObjectMetadataRequest>().Key;
|
||||
|
||||
if (!writtenObjects.TryGetValue(key, out var owner))
|
||||
throw new AmazonS3Exception("not found") { StatusCode = System.Net.HttpStatusCode.NotFound };
|
||||
|
||||
return owner is null ? new GetObjectMetadataResponse() : MetadataResponse(owner);
|
||||
});
|
||||
|
||||
s3.ListObjectsV2Async(Arg.Any<ListObjectsV2Request>(), Arg.Any<CancellationToken>())
|
||||
.Returns(_ => new ListObjectsV2Response { IsTruncated = false });
|
||||
|
||||
s3.CopyObjectAsync(Arg.Any<CopyObjectRequest>(), Arg.Any<CancellationToken>())
|
||||
.Returns(_ => new CopyObjectResponse());
|
||||
|
||||
s3.PutObjectAsync(Arg.Any<PutObjectRequest>(), Arg.Any<CancellationToken>())
|
||||
.Returns(call =>
|
||||
{
|
||||
var request = call.Arg<PutObjectRequest>();
|
||||
writtenObjects[request.Key] = request.Metadata["efecte-org-id"];
|
||||
return new PutObjectResponse();
|
||||
});
|
||||
|
||||
s3.DeleteObjectsAsync(Arg.Any<DeleteObjectsRequest>(), Arg.Any<CancellationToken>())
|
||||
.Returns(_ => new DeleteObjectsResponse());
|
||||
|
||||
return s3;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user