@@ -259,16 +259,23 @@ func (suite *TestSuiteStandard) TestRename() {
259259 // Account we import to
260260 internalAccount := suite .createTestAccount (models.AccountCreate {BudgetID : budget .Data .ID , Name : "Envelope Zero Account" })
261261
262+ // Test envelope and test transaction to the Edeka account with an envelope to test the envelope prefill
263+ envelope := suite .createTestEnvelope (models.EnvelopeCreate {CategoryID : suite .createTestCategory (models.CategoryCreate {BudgetID : budget .Data .ID }).Data .ID })
264+ envelopeID := envelope .Data .ID
265+ _ = suite .createTestTransaction (models.TransactionCreate {BudgetID : budget .Data .ID , SourceAccountID : internalAccount .Data .ID , DestinationAccountID : edeka .Data .ID , EnvelopeID : & envelopeID , Amount : decimal .NewFromFloat (12.00 )})
266+
262267 tests := []struct {
263268 name string // Name of the test
264269 sourceAccountIDs []uuid.UUID // The IDs of the source accounts
265270 destinationAccountIDs []uuid.UUID // The IDs of the destination accounts
271+ envelopeIDs []* uuid.UUID // expected IDs of envelopes
266272 preTest func (* testing.T ) [3 ]uuid.UUID // Function to execute before running tests
267273 }{
268274 {
269275 "Rule for Edeka" ,
270276 []uuid.UUID {internalAccount .Data .ID , internalAccount .Data .ID , uuid .Nil },
271277 []uuid.UUID {edeka .Data .ID , uuid .Nil , internalAccount .Data .ID },
278+ []* uuid.UUID {& envelopeID , nil , nil },
272279 func (t * testing.T ) [3 ]uuid.UUID {
273280 edeka := suite .createTestRenameRule (t , models.RenameRuleCreate {
274281 Match : "EDEKA*" ,
@@ -282,6 +289,7 @@ func (suite *TestSuiteStandard) TestRename() {
282289 "Rule for Edeka and DB" ,
283290 []uuid.UUID {internalAccount .Data .ID , internalAccount .Data .ID , uuid .Nil },
284291 []uuid.UUID {edeka .Data .ID , bahn .Data .ID , internalAccount .Data .ID },
292+ []* uuid.UUID {& envelopeID , nil , nil },
285293 func (t * testing.T ) [3 ]uuid.UUID {
286294 edeka := suite .createTestRenameRule (t , models.RenameRuleCreate {
287295 Match : "EDEKA*" ,
@@ -314,6 +322,8 @@ func (suite *TestSuiteStandard) TestRename() {
314322 }
315323
316324 assert .Equal (t , renameRuleIDs [i ], transaction .RenameRuleID , "Expected rename rule has match '%s', actual rename rule has match '%s'" , renameRuleIDs [i ])
325+
326+ assert .Equal (t , tt .envelopeIDs [i ], transaction .Transaction .EnvelopeID , "proposed envelope ID does not match in line %d" , line )
317327 }
318328
319329 // Delete rename rules
0 commit comments