Skip to content

Commit

Permalink
fix: add input testcase corresponding to mock response
Browse files Browse the repository at this point in the history
  • Loading branch information
Lakshay Kalbhor committed Jul 27, 2023
1 parent 84ababc commit a881e5c
Showing 1 changed file with 37 additions and 13 deletions.
50 changes: 37 additions & 13 deletions margins_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,26 +109,50 @@ func (ts *TestSuite) TestGetOrderCharges(t *testing.T) {
t.Parallel()

params :=
OrderChargesParam{
Exchange: "NSE",
Tradingsymbol: "INFY",
TransactionType: "BUY",
Variety: "regular",
Product: "CNC",
OrderType: "MARKET",
Quantity: 1,
AveragePrice: 10,
OrderID: "11111",
[]OrderChargesParam{
{
Exchange: "SBIN",
Tradingsymbol: "INFY",
TransactionType: "BUY",
Variety: "regular",
Product: "CNC",
OrderType: "MARKET",
Quantity: 1,
AveragePrice: 560,
OrderID: "11111",
},
{
Exchange: "MCX",
Tradingsymbol: "GOLDPETAL23JULFUT",
TransactionType: "SELL",
Variety: "regular",
Product: "NRML",
OrderType: "LIMIT",
Quantity: 1,
AveragePrice: 5862,
OrderID: "11111",
},
{
Exchange: "NFO",
Tradingsymbol: "NIFTY2371317900PE",
TransactionType: "BUY",
Variety: "regular",
Product: "NRML",
OrderType: "LIMIT",
Quantity: 100,
AveragePrice: 1.5,
OrderID: "11111",
},
}

orderResponseCharges, err := ts.KiteConnect.GetOrderCharges(GetChargesParams{
OrderParams: []OrderChargesParam{params},
OrderParams: params,
})
if err != nil {
t.Errorf("Error while getting compact basket order margins: %v", err)
t.Errorf("Error while getting order charges: %v", err)
}

if len(orderResponseCharges) != 1 {
t.Errorf("Incorrect response, expected len(orderResponseBasket.Orders) to be 2, got: %v", len(orderResponseCharges))
t.Errorf("Incorrect response, expected len(orderResponseCharges) to be 3, got: %v", len(orderResponseCharges))
}
}

0 comments on commit a881e5c

Please sign in to comment.