add async feature #1
@ -218,37 +218,12 @@ pub mod reader_sync {
|
||||
}
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use crate::source::SourceQuestion;
|
||||
|
||||
use super::super::test::sample_batch;
|
||||
use super::*;
|
||||
use std::fs;
|
||||
use std::{io::Write, iter, path::Path};
|
||||
use tempfile::tempdir;
|
||||
|
||||
use super::SourceQuestionsBatch;
|
||||
|
||||
fn sample_batch() -> SourceQuestionsBatch {
|
||||
SourceQuestionsBatch {
|
||||
description: "Тестовый".into(),
|
||||
date: "00-000-2000".into(),
|
||||
questions: vec![
|
||||
SourceQuestion {
|
||||
id: "Вопрос 1".into(),
|
||||
description: "Сколько будет (2 * 2 * 2 + 2) * 2 * 2 + 2".into(),
|
||||
answer: "42".into(),
|
||||
..Default::default()
|
||||
},
|
||||
SourceQuestion {
|
||||
id: "Вопрос 2".into(),
|
||||
description: "Зимой и летом одним цветом".into(),
|
||||
answer: "ёлка".into(),
|
||||
..Default::default()
|
||||
},
|
||||
],
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
fn write_sample_zip<P>(path: P)
|
||||
where
|
||||
P: AsRef<Path>,
|
||||
@ -282,7 +257,7 @@ pub mod reader_sync {
|
||||
let mut source = zip_file.source_questions();
|
||||
assert_eq!(source.len(), 1);
|
||||
|
||||
let actual = source.nth(0).expect("get batch");
|
||||
let actual = source.next().expect("get batch");
|
||||
assert_eq!(actual.0, "test.json");
|
||||
assert_eq!(actual.1.expect("parse batch"), expected_batch);
|
||||
}
|
||||
@ -430,6 +405,7 @@ pub mod reader_async {
|
||||
mod test {
|
||||
use crate::source::SourceQuestion;
|
||||
|
||||
use super::super::test::sample_batch;
|
||||
use super::*;
|
||||
use async_zip::{base::write::ZipFileWriter, ZipEntryBuilder};
|
||||
use core::fmt::Debug;
|
||||
@ -438,28 +414,6 @@ pub mod reader_async {
|
||||
use tempfile::tempdir;
|
||||
use tokio::fs;
|
||||
|
||||
fn sample_batch() -> SourceQuestionsBatch {
|
||||
SourceQuestionsBatch {
|
||||
description: "Тестовый".into(),
|
||||
date: "00-000-2000".into(),
|
||||
questions: vec![
|
||||
SourceQuestion {
|
||||
id: "Вопрос 1".into(),
|
||||
description: "Сколько будет (2 * 2 * 2 + 2) * 2 * 2 + 2".into(),
|
||||
answer: "42".into(),
|
||||
..Default::default()
|
||||
},
|
||||
SourceQuestion {
|
||||
id: "Вопрос 2".into(),
|
||||
description: "Зимой и летом одним цветом".into(),
|
||||
answer: "ёлка".into(),
|
||||
..Default::default()
|
||||
},
|
||||
],
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
async fn write_sample_zip<P>(path: P)
|
||||
where
|
||||
P: AsRef<Path>,
|
||||
@ -547,9 +501,8 @@ mod test {
|
||||
use insta::assert_yaml_snapshot;
|
||||
use serde_json::json;
|
||||
|
||||
#[test]
|
||||
fn test_batch_ser() {
|
||||
let batch = SourceQuestionsBatch {
|
||||
pub fn sample_batch() -> SourceQuestionsBatch {
|
||||
SourceQuestionsBatch {
|
||||
description: "Тестовый".into(),
|
||||
date: "00-000-2000".into(),
|
||||
questions: vec![
|
||||
@ -567,7 +520,12 @@ mod test {
|
||||
},
|
||||
],
|
||||
..Default::default()
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_batch_ser() {
|
||||
let batch = sample_batch();
|
||||
|
||||
assert_yaml_snapshot!(batch, @r#"
|
||||
---
|
||||
|
Loading…
Reference in New Issue
Block a user