Skip to content

Commit

Permalink
test: Add assertion for non-empty data and multiple nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
anstadnik committed Oct 6, 2023
1 parent 2aebd73 commit cfac4fc
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build_and_test_bot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ jobs:
- name: Test and build release
if: inputs.release
env:
SHEET_ID: ${{ env.SHEET_ID }}
SHEET_ID: ${{ secrets.SHEET_ID }}
RUST_LOG: info
run: cargo test --release -- --nocapture && cargo build --release

- name: Test and build debug
if: ${{ !inputs.release }}
env:
SHEET_ID: ${{ env.SHEET_ID }}
SHEET_ID: ${{ secrets.SHEET_ID }}
RUST_LOG: info
run: cargo test -- --nocapture && cargo build

Expand Down
5 changes: 4 additions & 1 deletion core/src/model/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub mod prelude {
}

use self::finite_state::{Fs, Row};
use anyhow::{anyhow, Context};
use anyhow::{anyhow, bail, Context};
use bytes::Buf;
use csv::Reader;
use finite_state::MultilangFs;
Expand Down Expand Up @@ -42,6 +42,9 @@ fn get_finite_state(rdr: Reader<impl Read>, lang: Lang) -> anyhow::Result<Fs> {
.collect::<Result<Vec<Row>, _>>()
.context("Cannot parse csv")?;
rows.retain(|record| !record.is_empty());
if rows.is_empty() {
bail!("No data");
}
for r in rows.iter_mut() {
r.key = r.key.trim().to_string();
r.question = r.question.trim().to_string();
Expand Down
1 change: 1 addition & 0 deletions core/tests/test_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ pre-formatted fixed-width code block written in the Python programming language
get_data_from_file("../table.csv")?
};
assert!(!data.is_empty());
assert!(data.iter().all(|(_, fs)| fs.num_nodes() > 1));
data.into_iter()
.inspect(|(lang, fs)| log::info!("Testing {lang} with {} nodes", fs.num_nodes()))
.try_for_each(|(_, fs)| test_fs(fs))?;
Expand Down

0 comments on commit cfac4fc

Please sign in to comment.