@@ -206,16 +206,22 @@ func (suite *TestSuiteStandard) TestYnabImportFindAccounts() {
206206 // Account we import to
207207 internalAccount := suite .createTestAccount (models.AccountCreate {BudgetID : budget .Data .ID , Name : "Envelope Zero Account" })
208208
209+ // Test envelope and test transaction to the Edeka account with an envelope to test the envelope prefill
210+ envelope := suite .createTestEnvelope (models.EnvelopeCreate {CategoryID : suite .createTestCategory (models.CategoryCreate {BudgetID : budget .Data .ID }).Data .ID })
211+ envelopeID := envelope .Data .ID
212+ _ = suite .createTestTransaction (models.TransactionCreate {BudgetID : budget .Data .ID , SourceAccountID : internalAccount .Data .ID , DestinationAccountID : edeka .Data .ID , EnvelopeID : & envelopeID , Amount : decimal .NewFromFloat (12.00 )})
213+
209214 tests := []struct {
210- name string // Name of the test
211- sourceAccountIDs []uuid.UUID // The IDs of the source accounts
212- sourceAccountNames []string // The sourceAccountName attribute after the find has been performed
213- destinationAccountIDs []uuid.UUID // The IDs of the destination accounts
214- destinationAccountNames []string // The destinationAccountName attribute after the find has been performed
215- preTest func () // Function to execute before running tests
215+ name string // Name of the test
216+ sourceAccountIDs []uuid.UUID // The IDs of the source accounts
217+ sourceAccountNames []string // The sourceAccountName attribute after the find has been performed
218+ destinationAccountIDs []uuid.UUID // The IDs of the destination accounts
219+ destinationAccountNames []string // The destinationAccountName attribute after the find has been performed
220+ envelopeIDs []* uuid.UUID // expected IDs of envelopes
221+ preTest func () // Function to execute before running tests
216222 }{
217- {"No matching (Some Company) & 1 Matching (Edeka) accounts" , []uuid.UUID {internalAccount .Data .ID , internalAccount .Data .ID , uuid .Nil }, []string {"" , "" , "Some Company" }, []uuid.UUID {edeka .Data .ID , uuid .Nil , internalAccount .Data .ID }, []string {"" , "Deutsche Bahn" , "" }, func () {}},
218- {"Two matching non-archived accounts" , []uuid.UUID {internalAccount .Data .ID , internalAccount .Data .ID , uuid .Nil }, []string {"" , "" , "Some Company" }, []uuid.UUID {uuid .Nil , uuid .Nil , internalAccount .Data .ID }, []string {"Edeka" , "Deutsche Bahn" , "" }, func () {
223+ {"No matching (Some Company) & 1 Matching (Edeka) accounts" , []uuid.UUID {internalAccount .Data .ID , internalAccount .Data .ID , uuid .Nil }, []string {"" , "" , "Some Company" }, []uuid.UUID {edeka .Data .ID , uuid .Nil , internalAccount .Data .ID }, []string {"" , "Deutsche Bahn" , "" }, [] * uuid. UUID { & envelopeID , nil , nil }, func () {}},
224+ {"Two matching non-archived accounts" , []uuid.UUID {internalAccount .Data .ID , internalAccount .Data .ID , uuid .Nil }, []string {"" , "" , "Some Company" }, []uuid.UUID {uuid .Nil , uuid .Nil , internalAccount .Data .ID }, []string {"Edeka" , "Deutsche Bahn" , "" }, [] * uuid. UUID { nil , nil , nil }, func () {
219225 _ = suite .createTestAccount (models.AccountCreate {BudgetID : budget .Data .ID , Name : "Edeka" })
220226 }},
221227 }
@@ -230,6 +236,8 @@ func (suite *TestSuiteStandard) TestYnabImportFindAccounts() {
230236 assert .Equal (t , tt .sourceAccountNames [i ], transaction .SourceAccountName , "sourceAccountName does not match in line %d" , line )
231237 assert .Equal (t , tt .destinationAccountNames [i ], transaction .DestinationAccountName , "destinationAccountName does not match in line %d" , line )
232238
239+ assert .Equal (t , tt .envelopeIDs [i ], transaction .Transaction .EnvelopeID , "proposed envelope ID does not match in line %d" , line )
240+
233241 if tt .sourceAccountIDs [i ] != uuid .Nil {
234242 assert .Equal (t , tt .sourceAccountIDs [i ], transaction .Transaction .SourceAccountID , "sourceAccountID does not match in line %d" , line )
235243 }
0 commit comments