From 626342e9bb6798146f7ddc07a8c049ee1a0ef1bc Mon Sep 17 00:00:00 2001 From: Ahmet Alp Balkan Date: Wed, 20 Jun 2018 16:55:43 -0700 Subject: [PATCH] test-cli: add smoke test for currencyservice Signed-off-by: Ahmet Alp Balkan --- src/test-cli/main.go | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/test-cli/main.go b/src/test-cli/main.go index 644867b..74c9392 100644 --- a/src/test-cli/main.go +++ b/src/test-cli/main.go @@ -36,6 +36,10 @@ var ( envs: []string{"EMAIL_SERVICE_ADDR"}, f: testEmailService, }, + "currencyservice": { + envs: []string{"CURRENCY_SERVICE_ADDR"}, + f: testCurrencyService, + }, } ) @@ -248,3 +252,32 @@ func testEmailService() error { log.Printf("--> resp: %+v", resp) return nil } + +func testCurrencyService() error { + addr := os.Getenv("EMAIL_SERVICE_ADDR") + conn, err := grpc.Dial(addr, grpc.WithInsecure()) + if err != nil { + return err + } + defer conn.Close() + cl := pb.NewCurrencyServiceClient(conn) + log.Println("--- rpc GetSupportedCurrencies()") + listResp, err := cl.GetSupportedCurrencies(context.TODO(), &pb.Empty{}) + if err != nil { + return err + } + log.Printf("--> %v", listResp) + convertResp, err := cl.Convert(context.TODO(), &pb.ConversionRequest{ + From: &pb.Money{ + CurrencyCode: "CAD", + Amount: &pb.MoneyAmount{ + Decimal: 12, + Fractional: 25}, + }, + ToCode: "USD"}) + if err != nil { + return err + } + log.Printf("--> result: %+v", convertResp.GetResult()) + return nil +}