func changeAndUpdateTransaction(t *testing.T, transaction *dbmodels.Transaction) {
	transaction.PayerID = bson.NewObjectId()
	transaction.ReceiverID = bson.NewObjectId()
	transaction.Type = models.TransactionTypeCard
	transaction.Currency = "USD"

	err := UpdateTransaction(transaction)

	if err != nil {
		t.Fatal("The transaction document could not be updated!")
	}
}
Example #2
0
// CreateTransaction adds a new Transaction to the database
func CreateTransaction(transaction *dbmodels.Transaction) error {
	session, collection := service.Connect(collectionName)
	defer session.Close()

	if transaction.ID == "" {
		transaction.ID = bson.NewObjectId()
	}

	err := collection.Insert(transaction)

	return err
}