Skip to content

Commit

Permalink
feat: test deleted metadata event for transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
gfyrag committed Oct 16, 2024
1 parent 0df8df5 commit ae0ca70
Showing 1 changed file with 24 additions and 28 deletions.
52 changes: 24 additions & 28 deletions test/e2e/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,29 +174,6 @@ var _ = Context("Ledger integration tests", func() {
})))
})
})
Context("when adding a metadata on the newly created transaction", func() {
metadata := map[string]string{
"status": "succeeded",
}
JustBeforeEach(func() {
err := AddMetadataToTransaction(ctx, testServer.GetValue(), operations.V2AddMetadataOnTransactionRequest{
Ledger: createLedgerRequest.Ledger,
ID: tx.ID,
RequestBody: metadata,
})
Expect(err).To(BeNil())
})
It("should be ok", func() {
By("it should send an event", func() {
Eventually(events).Should(Receive(Event(ledgerevents.EventTypeSavedMetadata, bus.SavedMetadata{
Ledger: createLedgerRequest.Ledger,
TargetType: ledger.MetaTargetTypeTransaction,
TargetID: tx.ID.String(),
Metadata: metadata,
})))
})
})
})
It("should be listable on api", func() {
txs, err := ListTransactions(ctx, testServer.GetValue(), operations.V2ListTransactionsRequest{
Ledger: createLedgerRequest.Ledger,
Expand Down Expand Up @@ -262,13 +239,14 @@ var _ = Context("Ledger integration tests", func() {
})
})
When("adding a metadata on the transaction", func() {
metadata := map[string]string{
"foo": "bar",
}
JustBeforeEach(func() {
Expect(AddMetadataToTransaction(ctx, testServer.GetValue(), operations.V2AddMetadataOnTransactionRequest{
Ledger: createLedgerRequest.Ledger,
ID: tx.ID,
RequestBody: map[string]string{
"foo": "bar",
},
Ledger: createLedgerRequest.Ledger,
ID: tx.ID,
RequestBody: metadata,
})).To(BeNil())
})
It("should be ok", func() {
Expand All @@ -278,6 +256,15 @@ var _ = Context("Ledger integration tests", func() {
})
Expect(err).To(Succeed())
Expect(transaction.Metadata).To(HaveKeyWithValue("foo", "bar"))

By("it should send an event", func() {
Eventually(events).Should(Receive(Event(ledgerevents.EventTypeSavedMetadata, bus.SavedMetadata{
Ledger: createLedgerRequest.Ledger,
TargetType: ledger.MetaTargetTypeTransaction,
TargetID: tx.ID.String(),
Metadata: metadata,
})))
})
})
When("deleting metadata", func() {
JustBeforeEach(func() {
Expand All @@ -294,6 +281,15 @@ var _ = Context("Ledger integration tests", func() {
})
Expect(err).To(Succeed())
Expect(transaction.Metadata).NotTo(HaveKey("foo"))

By("it should send an event", func() {
Eventually(events).Should(Receive(Event(ledgerevents.EventTypeDeletedMetadata, bus.DeletedMetadata{
Ledger: createLedgerRequest.Ledger,
TargetType: ledger.MetaTargetTypeTransaction,
TargetID: tx.ID.String(),
Key: "foo",
})))
})
})
})
})
Expand Down

0 comments on commit ae0ca70

Please sign in to comment.