test-cli: add smoke test for currencyservice

Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>
This commit is contained in:
Ahmet Alp Balkan 2018-06-20 16:55:43 -07:00
parent 52cc8faef9
commit 626342e9bb

View file

@ -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
}