MCPcopy
hub / github.com/nakabonne/ali / TestFileExporter_Basic

Function TestFileExporter_Basic

export/export_test.go:15–102  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

13)
14
15func TestFileExporter_Basic(t *testing.T) {
16 dir := t.TempDir()
17 exporter := NewFileExporter(dir)
18 zone := time.FixedZone("JST", 9*60*60)
19
20 run, err := exporter.StartRun(Meta{
21 ID: "00000000-0000-0000-0000-000000000000",
22 TargetURL: "https://example.com/",
23 Method: "GET",
24 Rate: 50,
25 Duration: 2 * time.Second,
26 })
27 require.NoError(t, err)
28
29 results := []Result{
30 {
31 Timestamp: time.Date(2021, 3, 13, 15, 20, 43, 0, zone),
32 LatencyNS: 18234567,
33 StatusCode: 200,
34 },
35 {
36 Timestamp: time.Date(2021, 3, 13, 15, 20, 43, 20*int(time.Millisecond), zone),
37 LatencyNS: 44900123,
38 StatusCode: 200,
39 },
40 {
41 Timestamp: time.Date(2021, 3, 13, 15, 20, 43, 41*int(time.Millisecond), zone),
42 LatencyNS: 935489752,
43 StatusCode: 500,
44 },
45 }
46 for _, res := range results {
47 require.NoError(t, run.WriteResult(res))
48 }
49
50 summary := Summary{
51 Target: TargetSummary{
52 URL: "https://example.com/",
53 Method: "GET",
54 },
55 Parameters: ParametersSummary{
56 Rate: 50,
57 DurationSeconds: 2,
58 },
59 Timing: TimingSummary{
60 Earliest: time.Date(2021, 3, 13, 15, 20, 43, 0, zone),
61 Latest: time.Date(2021, 3, 13, 15, 20, 45, 0, zone),
62 },
63 Requests: RequestsSummary{
64 Count: 100,
65 SuccessRatio: 0.98,
66 },
67 Throughput: 48.24,
68 LatencyMS: LatencySummary{
69 Total: 44000,
70 Mean: 447.88,
71 P50: 445.46,
72 P90: 806.58,

Callers

nothing calls this directly

Calls 7

StartRunMethod · 0.95
NewFileExporterFunction · 0.85
readGoldenFunction · 0.85
readFileFunction · 0.85
summaryFilenameFunction · 0.85
WriteResultMethod · 0.80
CloseMethod · 0.80

Tested by

no test coverage detected