Skip to content

Commit

Permalink
test: add test for importer
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Dec 3, 2021
1 parent 70a92c0 commit cc70f52
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 5 deletions.
33 changes: 33 additions & 0 deletions _fixtures/import_test/todo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[
{
"displayName": "Flagged Emails",
"id": "AQMkADAwATM0MDAAMS04N2E2LWRhMDItMDACLTAwCgAuAAADlaHHnFnn1UuoFE2pMt0j5QEAaMraZPkN_0mltv0IMNqe5wAEmScfOgAAAA==",
"wellknownListName": "flaggedEmails",
"children": []
},
{
"displayName": "任务",
"id": "AQMkADAwATM0MDAAMS04N2E2LWRhMDItMDACLTAwCgAuAAADlaHHnFnn1UuoFE2pMt0j5QEAaMraZPkN_0mltv0IMNqe5wAAAgESAAAA",
"wellknownListName": "defaultList",
"children": [
{
"body": {
"content": "",
"contentType": "text"
},
"bodyLastModifiedDateTime": null,
"completedDateTime": null,
"createdDateTime": "2021-11-05T07:43:38.2189068Z",
"dueDateTime": null,
"id": "AQMkADAwATM0MDAAMS04N2E2LWRhMDItMDACLTAwCgBGAAADlaHHnFnn1UuoFE2pMt0j5QcAaMraZPkN_0mltv0IMNqe5wAAAgESAAAAaMraZPkN_0mltv0IMNqe5wAEy-HmfAAAAA==",
"importance": "normal",
"isReminderOn": false,
"lastModifiedDateTime": "2021-11-05T07:53:39.9007193Z",
"recurrence": null,
"reminderDateTime": null,
"status": "notStarted",
"title": "Game Develop"
}
]
}
]
2 changes: 1 addition & 1 deletion quake_analysis/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ fn is_markdown(entry: &DirEntry) -> bool {
}

fn main() {
count_by_path(PathBuf::from("_fixtures").join("phodal_com"));
count_by_path(PathBuf::from("_fixtures").join("blog"));
}

fn count_by_path(path: PathBuf) {
Expand Down
22 changes: 18 additions & 4 deletions quake_importer/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ fn main() {

#[cfg(test)]
mod tests {
use quake_core::entry::entry_file::EntryFile;
use std::fs;
use std::path::PathBuf;

Expand All @@ -126,12 +127,25 @@ mod tests {
let path = PathBuf::from("..").join("_fixtures").join("notes");
let _ = dump_apple_notes("../dbs/mac_apt.db", path);
}
#[ignore]

#[test]
fn dump_todo() {
let path = PathBuf::from("..").join("_fixtures").join("microsoft_todo");
let todo = fs::read_to_string("../dbs/todo-output.json").unwrap();
let output_dir = PathBuf::from("test_temp").join("todo");
fs::create_dir_all(&output_dir).unwrap();

let input = PathBuf::from("../")
.join("_fixtures")
.join("import_test")
.join("todo.json");

let todo = fs::read_to_string(format!("{:}", input.display())).unwrap();
let vec: Vec<OutputList> = serde_json::from_str(&*todo).unwrap();
let _ = dump_microsoft_todo(vec, &path);
let _ = dump_microsoft_todo(vec, &output_dir);

let str = fs::read_to_string(output_dir.join("0001-game-develop.md")).unwrap();
let file = EntryFile::from(str.as_str(), 1).unwrap();

assert_eq!(file.field("title").unwrap(), "Game Develop");
// fs::remove_dir_all(output_dir).unwrap();
}
}
3 changes: 3 additions & 0 deletions quake_importer/test_temp/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*
!.gitignore

0 comments on commit cc70f52

Please sign in to comment.