run live test on ci

This commit is contained in:
philipp 2023-11-06 13:36:33 +01:00
parent 3f2e4eed05
commit 16862adead
3 changed files with 399 additions and 441 deletions

View File

@ -4,4 +4,4 @@ test:
stage: test stage: test
image: rust:latest image: rust:latest
script: script:
- cargo test --verbose - cargo test --verbose -- --include-ignored

File diff suppressed because it is too large Load Diff

View File

@ -2,7 +2,7 @@ use log::debug;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::sync::Arc; use std::sync::Arc;
use crate::overview; use crate::{overview, par};
#[derive(Debug, Serialize, Deserialize, PartialEq)] #[derive(Debug, Serialize, Deserialize, PartialEq)]
pub(crate) struct Law { pub(crate) struct Law {
@ -182,7 +182,14 @@ impl LawBuilder {
history: Vec::new(), history: Vec::new(),
}; };
overview::parse(law_id.unwrap()).unwrap(); let paragraphs = overview::parse(law_id.unwrap()).unwrap();
for paragraph in paragraphs {
let cont = par::parse(&paragraph, &mut builder).unwrap();
if !cont {
break;
}
}
builder.into() builder.into()
} }
@ -436,75 +443,11 @@ pub(crate) enum Content {
List(Vec<Box<Content>>), List(Vec<Box<Content>>),
} }
//#[cfg(test)]
//mod tests {
// use super::*;
//
// //#[test]
// //fn atest() {
// // let mut builder = LawBuilder::test("test");
// // builder.new_header("h11");
// // builder.new_par("§11".into(), Content::Text("hi".into()));
// // builder.new_header("h21");
// // builder.new_header("h31");
// // builder.new_par("§211".into(), Content::Text("hi".into()));
// // builder.new_par("§212".into(), Content::Text("hi".into()));
// // builder.new_header("h22");
// // builder.new_par("§22".into(), Content::Text("hi".into()));
//
// // let law: Law = builder.into();
//
// // println!("{law:#?}");
// // assert!(false);
// //}
//
// // #[test]
// // fn test() {
// // let mut builder = LawBuilder::test("UrhG");
// //
// // builder.new_header("1. Hauptstück");
// // builder.new_header("2. Abschnitt");
// //
// // builder.new_par(Content::Text("Mein erster Paragraph".into()));
// //
// // let expected = LawBuilder {
// // name: "UrhG".into(),
// // classifiers: vec![
// // Classifier {
// // name: "Hauptstück".into(),
// // parent: None,
// // instances: vec![ClassifierInstance {
// // name: "1. Hauptstück".into(),
// // desc: None,
// // content: vec![],
// // }],
// // },
// // Classifier {
// // name: "Abschnitt".into(),
// // parent: Some(Box::new(Classifier {
// // name: "Hauptstück".into(),
// // parent: None,
// // instances: vec![],
// // })),
// // instances: vec![ClassifierInstance {
// // name: "2. Abschnitt".into(),
// // desc: None,
// // content: vec![Content::Text("Mein erster Paragraph".into())],
// // }],
// // },
// // ],
// // next_para_header: None,
// // last_header_index: Some(1),
// // };
// // assert_eq!(builder, expected);
// // }
//}
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use pretty_assertions::assert_eq; use pretty_assertions::assert_eq;
use std::{ use std::{
fs::{self, File}, fs::File,
io::{self, BufRead, Read}, io::{self, BufRead, Read},
path::Path, path::Path,
}; };
@ -520,6 +463,21 @@ mod tests {
buf_reader.lines().collect() buf_reader.lines().collect()
} }
#[ignore]
#[test]
fn test_with_live_data() {
let law = LawBuilder::new("UrhG");
let path = Path::new("./data/urhg/builder.result");
let mut file = File::open(path).unwrap();
let mut json = String::new();
file.read_to_string(&mut json).unwrap();
let expected: Law = serde_json::from_str(&json).unwrap();
assert_eq!(law, expected);
}
#[test] #[test]
fn test_builder_full_urhg() { fn test_builder_full_urhg() {
let mut builder = LawBuilder::test("UrhG"); let mut builder = LawBuilder::test("UrhG");