Skip to content

Commit a87e492

Browse files
committed
fix tests
1 parent 2acfb66 commit a87e492

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

libraries/tests/AWS.Lambda.Powertools.Idempotency.Tests/IdempotencyTest.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
*/
1515

1616
using System;
17+
using System.Collections.Generic;
1718
using System.IO;
1819
using System.Text.Json;
1920
using System.Threading.Tasks;
@@ -68,6 +69,13 @@ public async Task EndToEndTest()
6869
TableName = _tableName
6970
});
7071
scanResponse.Count.Should().Be(1);
72+
73+
// delete row dynamo
74+
var key = new Dictionary<string, AttributeValue>
75+
{
76+
["id"] = new AttributeValue { S = "testFunction.GetPageContents#ff323c6f0c5ceb97eed49121babcec0f" }
77+
};
78+
await _client.DeleteItemAsync(new DeleteItemRequest{TableName = _tableName, Key = key});
7179
}
7280

7381
[Fact]
@@ -96,13 +104,22 @@ public async Task EndToEndTestMethod()
96104
var response2 = await function.Handle(request, context);
97105
function.MethodCalled.Should().BeFalse();
98106

99-
JsonSerializer.Serialize(response).Should().Be(JsonSerializer.Serialize(response));
107+
// Assert
108+
JsonSerializer.Serialize(response).Should().Be(JsonSerializer.Serialize(response2));
109+
response.Body.Should().Contain("hello world");
100110
response2.Body.Should().Contain("hello world");
101111

102112
var scanResponse = await _client.ScanAsync(new ScanRequest
103113
{
104114
TableName = _tableName
105115
});
106116
scanResponse.Count.Should().Be(1);
117+
118+
// delete row dynamo
119+
var key = new Dictionary<string, AttributeValue>
120+
{
121+
["id"] = new AttributeValue { S = "testFunction.GetPageContents#ff323c6f0c5ceb97eed49121babcec0f" }
122+
};
123+
await _client.DeleteItemAsync(new DeleteItemRequest{TableName = _tableName, Key = key});
107124
}
108125
}

libraries/tests/AWS.Lambda.Powertools.Idempotency.Tests/Internal/IdempotentAspectTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,8 @@ public void Handle_WhenIdempotencyOnSubMethodAnnotated_AndSecondCall_AndNotExpir
310310
{
311311
// Arrange
312312
var store = Substitute.For<BasePersistenceStore>();
313-
store.SaveInProgress(Arg.Any<JsonDocument>(), Arg.Any<DateTimeOffset>(), null)
314-
.Throws(new IdempotencyItemAlreadyExistsException());
313+
store.SaveInProgress(Arg.Any<JsonDocument>(), Arg.Any<DateTimeOffset>(), Arg.Any<double>())
314+
.Returns(_ => throw new IdempotencyItemAlreadyExistsException());
315315

316316
Idempotency.Configure(builder => builder.WithPersistenceStore(store));
317317

@@ -327,7 +327,7 @@ public void Handle_WhenIdempotencyOnSubMethodAnnotated_AndSecondCall_AndNotExpir
327327
.Returns(record);
328328

329329
// Act
330-
var function = new IdempotencyInternalFunction(false);
330+
var function = new IdempotencyInternalFunction(true);
331331
Basket resultBasket = function.HandleRequest(product, new TestLambdaContext());
332332

333333
// assert

0 commit comments

Comments
 (0)