mirror of
https://github.com/0xrsydn/idx-cli.git
synced 2026-11-07 09:45:36 +00:00
test(smoke): live cases for the Stockbit session (orderbook, actions, calendar)
Run only when `idx stockbit status` reports a session. They keep the user's real config directory, which holds the session: an isolated copy would refresh on its own and spend the user's rotating refresh token. Claude-Session: https://claude.ai/code/session_01RqPPVeVDrnLoP7NUZmLRxY
This commit is contained in:
parent
43ff4aa433
commit
73735767bb
1 changed files with 20 additions and 2 deletions
|
|
@ -71,10 +71,14 @@ LOG_DIR="$WORKDIR/logs"
|
||||||
COMMON_ENV=("IDX_PROVIDER=msn" "IDX_HISTORY_PROVIDER=auto" "IDX_NO_COLOR=1")
|
COMMON_ENV=("IDX_PROVIDER=msn" "IDX_HISTORY_PROVIDER=auto" "IDX_NO_COLOR=1")
|
||||||
|
|
||||||
# Each binary gets its own config, cache, and data so both really fetch.
|
# Each binary gets its own config, cache, and data so both really fetch.
|
||||||
|
# Stockbit session cases keep the user's real config directory, which holds
|
||||||
|
# the session: a copy would refresh on its own and spend the user's rotating
|
||||||
|
# refresh token, while the real file is shared under its lock.
|
||||||
|
REAL_CONFIG=0
|
||||||
side_env() {
|
side_env() {
|
||||||
local home="$WORKDIR/$1"
|
local home="$WORKDIR/$1"
|
||||||
printf '%s\n' "XDG_CONFIG_HOME=$home/config" "XDG_CACHE_HOME=$home/cache" \
|
(( REAL_CONFIG )) || printf '%s\n' "XDG_CONFIG_HOME=$home/config"
|
||||||
"XDG_DATA_HOME=$home/data" "${COMMON_ENV[@]}"
|
printf '%s\n' "XDG_CACHE_HOME=$home/cache" "XDG_DATA_HOME=$home/data" "${COMMON_ENV[@]}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Values of these commands should not move between two back-to-back runs.
|
# Values of these commands should not move between two back-to-back runs.
|
||||||
|
|
@ -128,6 +132,10 @@ contract() {
|
||||||
echo '(.highlights | type == "array") and (.risks | type == "array")' ;;
|
echo '(.highlights | type == "array") and (.risks | type == "array")' ;;
|
||||||
"stocks news "*)
|
"stocks news "*)
|
||||||
echo 'type == "array" and all(.[]; (.title | type == "string") and (.url | type == "string"))' ;;
|
echo 'type == "array" and all(.[]; (.title | type == "string") and (.url | type == "string"))' ;;
|
||||||
|
"stocks orderbook "*)
|
||||||
|
echo '(.symbol | type == "string") and (.price | type == "number") and (.market_status | type == "string") and (.bids | type == "array") and (.offers | type == "array")' ;;
|
||||||
|
"stocks actions "*|"stocks calendar"*)
|
||||||
|
echo 'type == "array" and length > 0 and all(.[]; (.symbol | type == "string") and (.kind | type == "string") and (.date | type == "string"))' ;;
|
||||||
"stocks broker "*)
|
"stocks broker "*)
|
||||||
echo '(.symbol | type == "string") and (.buyers | length > 0) and (.sellers | length > 0) and all(.buyers[]; (.code | type == "string") and (.value | type == "number")) and (.total_value | type == "number")' ;;
|
echo '(.symbol | type == "string") and (.buyers | length > 0) and (.sellers | length > 0) and all(.buyers[]; (.code | type == "string") and (.value | type == "number")) and (.total_value | type == "number")' ;;
|
||||||
"stocks bandar "*)
|
"stocks bandar "*)
|
||||||
|
|
@ -253,6 +261,16 @@ if selected stockbit; then
|
||||||
run_new_case intraday "stocks intraday $SYMBOL"
|
run_new_case intraday "stocks intraday $SYMBOL"
|
||||||
run_new_case intraday-index "stocks intraday ^JKSE"
|
run_new_case intraday-index "stocks intraday ^JKSE"
|
||||||
run_new_case quote-stockbit "--provider stockbit stocks quote $SYMBOL"
|
run_new_case quote-stockbit "--provider stockbit stocks quote $SYMBOL"
|
||||||
|
# With the user's own session (`idx stockbit login`), if there is one.
|
||||||
|
if (( DRY_RUN )) || "${BIN_PATH:-idx}" -o json stockbit status 2>/dev/null | jq -e '.logged_in' >/dev/null; then
|
||||||
|
REAL_CONFIG=1
|
||||||
|
run_new_case orderbook "stocks orderbook $SYMBOL --depth 5"
|
||||||
|
run_new_case actions "stocks actions $SYMBOL --kind dividend,split"
|
||||||
|
run_new_case calendar "stocks calendar --kind dividend,rights"
|
||||||
|
REAL_CONFIG=0
|
||||||
|
else
|
||||||
|
echo " no Stockbit session: orderbook, actions and calendar not run"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if selected ownership; then
|
if selected ownership; then
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue