FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
alpaca-cpp/tests/data_client_tests.cpp at main · SlickQuant/alpaca-cpp · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
SlickQuant
/
alpaca-cpp
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
2
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
alpaca-cpp
/
tests
/
data_client_tests.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
62 lines (50 loc) · 2.45 KB
Breadcrumbs
alpaca-cpp
/
tests
/
data_client_tests.cpp
Copy path
File metadata and controls
62 lines (50 loc) · 2.45 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//
SPDX-License-Identifier: MIT
//
Copyright (c) 2026 Slick Quant
//
https://github.com/SlickQuant/alpaca-cpp
//
//
Offline tests for Market Data client construction. Nothing here touches the network:
//
non-empty credentials short-circuit `credentials::resolve`, so the constructors only
//
pick a base URL and record the environment.
#
include
<
gtest/gtest.h
>
#
include
<
alpaca/data_client.hpp
>
#
include
<
alpaca/data_client_awaitable.hpp
>
#
include
<
alpaca/environment.hpp
>
namespace
alpaca
::tests {
namespace
{
credentials
test_creds
() {
return
credentials
(
"
PKTEST
"
,
"
secret
"
); }
}
//
namespace
//
`data.alpaca.markets` is not account-scoped, so the environment shows up only in the
//
key pair the client resolved and — for sandbox — in the base URL. Keeping env()
//
readable is what makes the stored environment observable at all.
TEST
(DataClient, RecordsTheEnvironmentItWasBuiltFor) {
const
data_client
paper
(
test_creds
(), environment::paper);
EXPECT_EQ
(paper.
env
(), environment::paper);
EXPECT_EQ
(paper.
base_url
(), urls::market_data);
const
data_client
live
(
test_creds
(), environment::live);
EXPECT_EQ
(live.
env
(), environment::live);
EXPECT_EQ
(live.
base_url
(), urls::market_data);
const
data_client
sandbox
(
test_creds
(), environment::sandbox);
EXPECT_EQ
(sandbox.
env
(), environment::sandbox);
EXPECT_EQ
(sandbox.
base_url
(), urls::sandbox_data);
}
//
The explicit-base-URL constructor has no environment argument; it resolves paper
//
credentials, so that is what env() must report.
TEST
(DataClient, ExplicitBaseUrlReportsPaper) {
const
data_client
client
(
test_creds
(),
std::string
(
"
https://proxy.example.com
"
));
EXPECT_EQ
(client.
env
(), environment::paper);
EXPECT_EQ
(client.
base_url
(),
"
https://proxy.example.com
"
);
}
TEST
(DataClientAwaitable, RecordsTheEnvironmentItWasBuiltFor) {
const
data_client_awaitable
paper
(
test_creds
(), environment::paper);
EXPECT_EQ
(paper.
env
(), environment::paper);
EXPECT_EQ
(paper.
base_url
(), urls::market_data);
const
data_client_awaitable
sandbox
(
test_creds
(), environment::sandbox);
EXPECT_EQ
(sandbox.
env
(), environment::sandbox);
EXPECT_EQ
(sandbox.
base_url
(), urls::sandbox_data);
}
TEST
(DataClientAwaitable, ExplicitBaseUrlReportsPaper) {
const
data_client_awaitable
client
(
test_creds
(),
std::string
(
"
https://proxy.example.com
"
));
EXPECT_EQ
(client.
env
(), environment::paper);
EXPECT_EQ
(client.
base_url
(),
"
https://proxy.example.com
"
);
}
}
//
namespace alpaca::tests
Back
|
FazBrowse Home
|
New Git URL