Skip to content

Commit 5be66a6

Browse files
authored
Merge pull request #3 from scripbox/task/add-test-action
Add test action
2 parents e322b16 + cccb22c commit 5be66a6

File tree

4 files changed

+66
-5
lines changed

4 files changed

+66
-5
lines changed

.github/workflows/elixir.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Elixir CI
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
build:
11+
12+
name: Build and test
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v2
17+
- name: Set up Elixir
18+
uses: erlef/setup-elixir@885971a72ed1f9240973bd92ab57af8c1aa68f24
19+
with:
20+
elixir-version: '1.9.1' # Define the elixir version [required]
21+
otp-version: '22.3' # Define the OTP version [required]
22+
- name: Restore dependencies cache
23+
uses: actions/cache@v2
24+
with:
25+
path: deps
26+
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}
27+
restore-keys: ${{ runner.os }}-mix-
28+
- name: Install dependencies
29+
run: mix deps.get
30+
- name: Run tests
31+
run: mix test

lib/kite_connect_ex/user.ex

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,9 @@ defmodule KiteConnectEx.User do
9090
Request.get(url, nil, auth_header(access_token), KiteConnectEx.request_options())
9191
|> case do
9292
{:ok, data} ->
93-
funds_and_margins = FundAndMargin.new(data)
94-
|> Map.put(:margin_data, data)
93+
funds_and_margins =
94+
FundAndMargin.new(data)
95+
|> Map.put(:margin_data, data)
9596

9697
{:ok, funds_and_margins}
9798

lib/kite_connect_ex/user/fund_and_margin.ex

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,16 @@ defmodule KiteConnectEx.User.FundAndMargin do
1212
enabled: false,
1313
net: nil,
1414
available: nil,
15-
utilised: nil
15+
utilised: nil,
16+
margin_data: nil
1617
]
1718

1819
@type t :: %__MODULE__{
1920
enabled: Bool.t(),
2021
net: Float.t(),
2122
available: %AvailableSegment{},
22-
utilised: %UtilisedSegment{}
23+
utilised: %UtilisedSegment{},
24+
margin_data: %{}
2325
}
2426

2527
@derive {Jason.Encoder, only: Keyword.keys(@keys)}
@@ -30,7 +32,8 @@ defmodule KiteConnectEx.User.FundAndMargin do
3032
enabled: attributes["enabled"],
3133
net: attributes["net"],
3234
available: AvailableSegment.new(attributes["available"]),
33-
utilised: UtilisedSegment.new(attributes["utilised"])
35+
utilised: UtilisedSegment.new(attributes["utilised"]),
36+
margin_data: attributes["margin_data"]
3437
})
3538
end
3639

test/kite_connect_ex_test.exs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,32 @@ defmodule KiteConnectExTest do
175175
payout: 0,
176176
span: 0,
177177
turnover: 0
178+
},
179+
margin_data: %{
180+
"available" => %{
181+
"adhoc_margin" => 0,
182+
"cash" => 622.32,
183+
"collateral" => 0,
184+
"intraday_payin" => 0,
185+
"live_balance" => 622.32,
186+
"opening_balance" => 622.32
187+
},
188+
"enabled" => true,
189+
"net" => 622.32,
190+
"utilised" => %{
191+
"debits" => 0,
192+
"delivery" => 0,
193+
"exposure" => 0,
194+
"holding_sales" => 0,
195+
"liquid_collateral" => 0,
196+
"m2m_realised" => 0,
197+
"m2m_unrealised" => 0,
198+
"option_premium" => 0,
199+
"payout" => 0,
200+
"span" => 0,
201+
"stock_collateral" => 0,
202+
"turnover" => 0
203+
}
178204
}
179205
}}
180206
end

0 commit comments

Comments
 (0)