From 44e6671727179f2aa54169f5672cfd17459e43d1 Mon Sep 17 00:00:00 2001 From: Ahmet Alp Balkan Date: Tue, 19 Jun 2018 23:04:39 -0700 Subject: [PATCH] test-cli: add smoke test for shippingservice Signed-off-by: Ahmet Alp Balkan --- src/test-cli/main.go | 50 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/src/test-cli/main.go b/src/test-cli/main.go index 211921d..d595478 100644 --- a/src/test-cli/main.go +++ b/src/test-cli/main.go @@ -20,6 +20,10 @@ var ( envs: []string{"PRODUCT_CATALOG_SERVICE_ADDR"}, f: testProductCatalogService, }, + "shippingservice": { + envs: []string{"SHIPPING_SERVICE_ADDR"}, + f: testShippingService, + }, } ) @@ -76,3 +80,49 @@ func testProductCatalogService() error { return nil } + +func testShippingService() error { + addr := os.Getenv("SHIPPING_SERVICE_ADDR") + conn, err := grpc.Dial(addr, grpc.WithInsecure()) + if err != nil { + return err + } + defer conn.Close() + + address := &pb.Address{ + StreetAddress_1: "Muffin Man", + StreetAddress_2: "Drury Lane", + City: "London", + Country: "England", + } + items := []*pb.CartItem{ + { + ProductId: "23", + Quantity: 10, + }, + { + ProductId: "46", + Quantity: 3, + }, + } + + log.Println("--- rpc GetQuote()") + cl := pb.NewShippingServiceClient(conn) + quoteResp, err := cl.GetQuote(context.TODO(), &pb.GetQuoteRequest{ + Address: address, + Items: items}) + if err != nil { + return err + } + log.Printf("--> quote: %+v", quoteResp) + + log.Println("--- rpc ShipOrder()") + shipResp, err := cl.ShipOrder(context.TODO(), &pb.ShipOrderRequest{ + Address: address, + Items: items}) + if err != nil { + return err + } + log.Printf("--> quote: %+v", shipResp) + return nil +}