Files
gridcraft/crates/engine/tests/it/pivot_unknown_func.rs
T
aiongg a7608ada6d CI: one test binary per crate, nextest, line tables only (#2372)
* CI: dev builds keep line tables only

* CI: one integration-test binary per crate

* CI: xtask runs tests with nextest, doctests apart, --keep-going on clippy and wasm

cargo xtask test runs the workspace tests (--lib --bins --tests) with cargo-nextest when it is installed, else cargo test, then the doctests. cargo xtask ci uses the same two steps.

* CI: docs name cargo xtask test

* CI: agent guides name the moved fuzz test

* CI: tests added on main join their crate's test binary
2026-10-23 12:59:46 -04:00

34 lines
1.1 KiB
Rust

use gridcraft_engine::Session;
use serde_json::json;
fn session() -> Session {
let mut s = Session::new();
s.new_workbook();
s.execute("range.setValues", json!({"range":"A1", "values":[["Region", "Sales"], ["East", "10"], ["East", "2"], ["West", "4"]]})).unwrap();
s
}
#[test]
fn insert_pivot_table_rejects_unknown_func() {
for func in ["stdev", "sumx"] {
let mut s = session();
let r = s.execute(
"insert.pivotTable",
json!({"source":"Sheet1!A1:B4", "destination":"Sheet1!F1", "rows":["Region"], "values":[{"field":"Sales", "func":func}]}),
);
assert!(r.is_err(), "unknown func `{func}` accepted silently");
assert!(s.doc().unwrap().wb.active().unwrap().pivots.is_empty());
}
}
#[test]
fn insert_pivot_table_accepts_known_func() {
let mut s = session();
s.execute(
"insert.pivotTable",
json!({"source":"Sheet1!A1:B4", "destination":"Sheet1!F1", "rows":["Region"], "values":[{"field":"Sales", "func":"stddev"}]}),
)
.unwrap();
assert_eq!(s.doc().unwrap().wb.active().unwrap().pivots.len(), 1);
}