test-cli: add smoke test for currencyservice
Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>
This commit is contained in:
parent
52cc8faef9
commit
626342e9bb
1 changed files with 33 additions and 0 deletions
|
@ -36,6 +36,10 @@ var (
|
||||||
envs: []string{"EMAIL_SERVICE_ADDR"},
|
envs: []string{"EMAIL_SERVICE_ADDR"},
|
||||||
f: testEmailService,
|
f: testEmailService,
|
||||||
},
|
},
|
||||||
|
"currencyservice": {
|
||||||
|
envs: []string{"CURRENCY_SERVICE_ADDR"},
|
||||||
|
f: testCurrencyService,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -248,3 +252,32 @@ func testEmailService() error {
|
||||||
log.Printf("--> resp: %+v", resp)
|
log.Printf("--> resp: %+v", resp)
|
||||||
return nil
|
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
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue