-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocessor_test.go
More file actions
125 lines (107 loc) · 2.83 KB
/
Copy pathprocessor_test.go
File metadata and controls
125 lines (107 loc) · 2.83 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
package aperiodic
import (
"os"
"path/filepath"
"strings"
"testing"
)
func TestCLI_Symbols_HyperliquidPerps(t *testing.T) {
requireAPIKey(t)
stdout, stderr, code := runCLI("symbols", "-exchange", "hyperliquid-perps")
if code != 0 {
t.Fatalf("expected exit code 0, got %d; stderr: %s", code, stderr)
}
lines := strings.Split(strings.TrimSpace(stdout), "\n")
if len(lines) == 0 {
t.Fatal("expected at least one symbol in output")
}
}
func TestCLI_OHLCV_HyperliquidPerps_Download(t *testing.T) {
requireAPIKey(t)
outputDir := t.TempDir()
stdout, stderr, code := runCLI(
"ohlcv",
"-exchange", "hyperliquid-perps",
"-symbol", "perpetual-BTC-USDC:USDC",
"-interval", "1d",
"-start-date", "2025-03-01",
"-end-date", "2025-04-01",
"-output-dir", outputDir,
)
if code != 0 {
t.Fatalf("expected exit code 0, got %d; stderr: %s", code, stderr)
}
if !strings.Contains(stdout, "Successfully downloaded") {
t.Errorf("expected success message, got: %s", stdout)
}
files, err := filepath.Glob(filepath.Join(outputDir, "*.parquet"))
if err != nil {
t.Fatalf("failed to glob output dir: %v", err)
}
if len(files) == 0 {
t.Fatal("expected at least one parquet file in output dir")
}
for _, f := range files {
info, err := os.Stat(f)
if err != nil {
t.Errorf("failed to stat %s: %v", f, err)
continue
}
if info.Size() == 0 {
t.Errorf("expected non-empty file %s", f)
}
}
}
func TestCLI_VTWAP_InvalidAPIKey(t *testing.T) {
t.Setenv("APERIODIC_API_URL", DefaultBaseURL)
t.Setenv("APERIODIC_API_KEY", "invalid-key")
outputDir := t.TempDir()
_, stderr, code := runCLI(
"vtwap",
"-exchange", "binance-futures",
"-symbol", "perpetual-ETH-USDT:USDT",
"-interval", "1d",
"-start-date", "2024-01-01",
"-end-date", "2024-02-01",
"-output-dir", outputDir,
)
if code != 1 {
t.Fatalf("expected exit code 1 for invalid API key, got %d; stderr: %s", code, stderr)
}
}
func TestCLI_VTWAP_Download(t *testing.T) {
requireAPIKey(t)
outputDir := t.TempDir()
stdout, stderr, code := runCLI(
"vtwap",
"-exchange", "binance-futures",
"-symbol", "perpetual-ETH-USDT:USDT",
"-interval", "1d",
"-start-date", "2024-01-01",
"-end-date", "2024-02-01",
"-output-dir", outputDir,
)
if code != 0 {
t.Fatalf("expected exit code 0, got %d; stderr: %s", code, stderr)
}
if !strings.Contains(stdout, "Successfully downloaded") {
t.Errorf("expected success message, got: %s", stdout)
}
files, err := filepath.Glob(filepath.Join(outputDir, "*.parquet"))
if err != nil {
t.Fatalf("failed to glob output dir: %v", err)
}
if len(files) == 0 {
t.Fatal("expected at least one parquet file in output dir")
}
for _, f := range files {
info, err := os.Stat(f)
if err != nil {
t.Errorf("failed to stat %s: %v", f, err)
continue
}
if info.Size() == 0 {
t.Errorf("expected non-empty file %s", f)
}
}
}