Created
August 30, 2021 06:57
-
-
Save percybolmer/b89c4e5c13d4a65487fe603c2d00dadb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package services | |
import ( | |
"testing" | |
"github.com/google/uuid" | |
"github.com/percybolmer/ddd-go/aggregate" | |
) | |
func Test_Tavern(t *testing.T) { | |
// Create OrderService | |
products := init_products(t) | |
os, err := NewOrderService( | |
WithMemoryCustomerRepository(), | |
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