Skip to content

Commit 7674be2

Browse files
MatSTFCInGitclaude
andcommitted
fix(server): move archiver_demo.db fixture into the crate so CI can find it
db::tests::archiver_demo_db_parses_and_yields_expected_record_count read <crate>/../demo/archiver_demo.db, but `.gitignore:33` excludes the whole demo/ directory, so no file under it has ever been tracked. The test could only pass where the file happened to exist on disk and failed on every fresh checkout: DbParseError { path: ".../spvirit-server/../demo/archiver_demo.db", message: "No such file or directory (os error 2)" } Follow the convention of the sibling test in the same module: keep the fixture inside the crate at examples/archiver_demo.db, alongside the already-tracked example.db, and read it from CARGO_MANIFEST_DIR/examples. This also decouples the assertion from demo/, whose copy is rewritten by archiver_demo_gen.py while the demo runs; the tracked snapshot keeps the 14-record count stable. Verified by running the test with demo/ renamed away, reproducing the CI condition. spvirit-server lib suite: 186 passed, 0 failed. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent d512492 commit 7674be2

2 files changed

Lines changed: 115 additions & 3 deletions

File tree

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# Archiver Appliance demo database - one PV per record type spserver can load.
2+
# Generated by archiver_demo_gen.py at 2026-07-16 19:47:14 - DO NOT EDIT while the generator runs.
3+
4+
# ---- analog inputs -------------------------------------------------------
5+
record(ai, "DEMO:AI:SINE") {
6+
field(DESC, "5 V sine, 30 s period, cycles alarm limits")
7+
field(VAL, "0.9380")
8+
field(EGU, "V")
9+
field(PREC, "3")
10+
field(LOPR, "-10")
11+
field(HOPR, "10")
12+
field(LOW, "-3")
13+
field(HIGH, "3")
14+
field(LOLO, "-4.5")
15+
field(HIHI, "4.5")
16+
}
17+
record(ai, "DEMO:AI:RAMP") {
18+
field(DESC, "0-100 % sawtooth, 60 s period")
19+
field(VAL, "23.50")
20+
field(EGU, "%")
21+
field(PREC, "1")
22+
field(LOPR, "0")
23+
field(HOPR, "100")
24+
}
25+
record(ai, "DEMO:AI:NOISE") {
26+
field(DESC, "Pseudo-noise around 50 degC")
27+
field(VAL, "49.365")
28+
field(EGU, "degC")
29+
field(PREC, "2")
30+
field(LOPR, "40")
31+
field(HOPR, "60")
32+
}
33+
record(ai, "DEMO:AI:FOLLOW") {
34+
field(DESC, "Server-side periodic scan copying DEMO:AO:SETPOINT")
35+
field(SCAN, "1 second")
36+
field(INP, "DEMO:AO:SETPOINT")
37+
field(EGU, "A")
38+
field(PREC, "3")
39+
field(LOPR, "0")
40+
field(HOPR, "10")
41+
}
42+
43+
# ---- analog output (writable via pvput) ----------------------------------
44+
record(ao, "DEMO:AO:SETPOINT") {
45+
field(DESC, "0-10 A triangle, 120 s period, accepts puts")
46+
field(VAL, "7.6502")
47+
field(EGU, "A")
48+
field(PREC, "3")
49+
field(LOPR, "0")
50+
field(HOPR, "10")
51+
field(DRVL, "0")
52+
field(DRVH, "10")
53+
}
54+
55+
# ---- binary ---------------------------------------------------------------
56+
record(bi, "DEMO:BI:PULSE") {
57+
field(DESC, "Square wave, toggles every 5 s")
58+
field(VAL, "0")
59+
field(ZNAM, "LOW")
60+
field(ONAM, "HIGH")
61+
}
62+
record(bo, "DEMO:BO:ENABLE") {
63+
field(DESC, "Toggles every 17 s, accepts puts")
64+
field(VAL, "0")
65+
field(ZNAM, "DISABLED")
66+
field(ONAM, "ENABLED")
67+
}
68+
69+
# ---- strings ---------------------------------------------------------------
70+
record(stringin, "DEMO:STR:CLOCK") {
71+
field(DESC, "Wall-clock time string")
72+
field(VAL, "2026-07-16 19:47:14")
73+
}
74+
record(stringout, "DEMO:STR:MODE") {
75+
field(DESC, "Rotating machine mode, accepts puts")
76+
field(VAL, "COOLDOWN")
77+
}
78+
79+
# ---- arrays ----------------------------------------------------------------
80+
record(waveform, "DEMO:WF:SINE") {
81+
field(DESC, "Scrolling sine snapshot, 64 doubles")
82+
field(FTVL, "DOUBLE")
83+
field(NELM, "64")
84+
field(VAL, "-0.977, -0.822, -0.541, -0.178, 0.212, 0.570, 0.841, 0.984, 0.977, 0.822, 0.541, 0.178, -0.212, -0.570, -0.841, -0.984, -0.977, -0.822, -0.541, -0.178, 0.212, 0.570, 0.841, 0.984, 0.977, 0.822, 0.541, 0.178, -0.212, -0.570, -0.841, -0.984, -0.977, -0.822, -0.541, -0.178, 0.212, 0.570, 0.841, 0.984, 0.977, 0.822, 0.541, 0.178, -0.212, -0.570, -0.841, -0.984, -0.977, -0.822, -0.541, -0.178, 0.212, 0.570, 0.841, 0.984, 0.977, 0.822, 0.541, 0.178, -0.212, -0.570, -0.841, -0.984")
85+
}
86+
record(waveform, "DEMO:WF:LABELS") {
87+
field(DESC, "String waveform with rotating labels")
88+
field(FTVL, "STRING")
89+
field(NELM, "4")
90+
field(VAL, "SLOT0-COOLDOWN, SLOT1-COOLDOWN, SLOT2-COOLDOWN, SLOT3-COOLDOWN")
91+
}
92+
record(aai, "DEMO:AAI:COUNTS") {
93+
field(DESC, "Counting int32 array, 16 elements")
94+
field(FTVL, "LONG")
95+
field(NELM, "16")
96+
field(VAL, "634, 641, 648, 655, 662, 669, 676, 683, 690, 697, 704, 711, 718, 725, 732, 739")
97+
}
98+
record(aao, "DEMO:AAO:GAINS") {
99+
field(DESC, "Breathing float32 gains, accepts puts")
100+
field(FTVL, "FLOAT")
101+
field(NELM, "8")
102+
field(VAL, "1.3459, 0.8831, 0.5278, 0.6066, 1.0471, 1.4443, 1.4330, 1.0236")
103+
}
104+
record(subArray, "DEMO:SUB:SLICE") {
105+
field(DESC, "First 8 samples of DEMO:WF:SINE, rescanned every 1 s")
106+
field(SCAN, "1 second")
107+
field(INP, "DEMO:WF:SINE")
108+
field(FTVL, "DOUBLE")
109+
field(INDX, "0")
110+
field(NELM, "8")
111+
field(MALM, "64")
112+
field(VAL, "-0.977, -0.822, -0.541, -0.178, 0.212, 0.570, 0.841, 0.984")
113+
}

spvirit-server/src/db.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,11 +1075,10 @@ mod tests {
10751075
#[test]
10761076
fn archiver_demo_db_parses_and_yields_expected_record_count() {
10771077
let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
1078-
.join("..")
1079-
.join("demo")
1078+
.join("examples")
10801079
.join("archiver_demo.db");
10811080
let recs = load_db_records(path.to_str().expect("utf8 path"), &HashMap::new())
1082-
.expect("demo/archiver_demo.db must parse");
1081+
.expect("examples/archiver_demo.db must parse");
10831082
assert_eq!(
10841083
recs.len(),
10851084
14,

0 commit comments

Comments
 (0)