Skip to content

Instantly share code, notes, and snippets.

@percybolmer
Created August 30, 2021 08:03
Show Gist options
  • Save percybolmer/98b25ba134a304085785dbfb0a21e54a to your computer and use it in GitHub Desktop.
Save percybolmer/98b25ba134a304085785dbfb0a21e54a to your computer and use it in GitHub Desktop.
func Test_MongoTavern(t *testing.T) {
// Create OrderService
products := init_products(t)
os, err := NewOrderService(
WithMongoCustomerRepository("mongodb://localhost:27017"),
WithMemoryProductRepository(products),
)
if err != nil {
t.Error(err)
}
tavern, err := NewTavern(WithOrderService(os))
if err != nil {
t.Error(err)
}
cust, err := aggregate.NewCustomer("Percy")
if err != nil {
t.Error(err)
}
err = os.customers.Add(cust)
if err != nil {
t.Error(err)
}
order := []uuid.UUID{
products[0].GetID(),
}
// Execute Order
err = tavern.Order(cust.GetID(), order)
if err != nil {
t.Error(err)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment