Skip to content

Commit

Permalink
Add pseudo-integration tests for modules with all options disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
msuchane committed Apr 7, 2021
1 parent 7fead10 commit 1d6c3b7
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 1 deletion.
22 changes: 22 additions & 0 deletions data/generated/minimal-assembly.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
ifdef::context[:parent-context-of-minimal-assembly: {context}]

ifndef::context[]
[id="minimal-assembly"]
endif::[]
ifdef::context[]
[id="minimal-assembly_{context}"]
endif::[]
= Minimal assembly

:context: minimal-assembly

[role="_abstract"]

== Prerequisites

[role="_additional-resources"]
== Additional resources (or Next steps)

ifdef::parent-context-of-minimal-assembly[:context: {parent-context-of-minimal-assembly}]
ifndef::parent-context-of-minimal-assembly[:!context:]

9 changes: 9 additions & 0 deletions data/generated/minimal-concept.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[id="minimal-concept_{context}"]
= Minimal concept

[role="_abstract"]

[role="_additional-resources"]
.Additional resources


15 changes: 15 additions & 0 deletions data/generated/minimal-procedure.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[id="minimal-procedure_{context}"]
= Minimal procedure

[role="_abstract"]

.Prerequisites

.Procedure

.Verification

[role="_additional-resources"]
.Additional resources


9 changes: 9 additions & 0 deletions data/generated/minimal-reference.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[id="minimal-reference_{context}"]
= Minimal reference

[role="_abstract"]

[role="_additional-resources"]
.Additional resources


68 changes: 67 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,14 @@ mod tests {
use crate::module::ModuleType;
use crate::Options;

// These values represent the default newdoc options.
fn basic_options() -> Options {
Options {
comments: true,
prefixes: true,
examples: true,
target_dir: ".".to_string(),
detect_directory: false,
detect_directory: true,
}
}

Expand Down Expand Up @@ -192,4 +193,69 @@ mod tests {

assert_eq!(reference.text, pre_generated);
}

// These values strip down the modules to the bare minimum.
fn minimal_options() -> Options {
Options {
comments: false,
prefixes: false,
examples: false,
target_dir: ".".to_string(),
detect_directory: true,
}
}

/// Test that we generate the assembly that we expect.
#[test]
fn test_minimal_assembly() {
let mod_type = &ModuleType::Assembly;
let mod_title = "Minimal assembly";
let options = minimal_options();
let assembly = Module::new(mod_type, mod_title, &options);

let pre_generated =
include_str!("../data/generated/minimal-assembly.adoc");

assert_eq!(assembly.text, pre_generated);
}

/// Test that we generate the concept module that we expect.
#[test]
fn test_minimal_concept() {
let mod_type = &ModuleType::Concept;
let mod_title = "Minimal concept";
let options = minimal_options();
let concept = Module::new(mod_type, mod_title, &options);

let pre_generated = include_str!("../data/generated/minimal-concept.adoc");

assert_eq!(concept.text, pre_generated);
}

/// Test that we generate the procedure module that we expect.
#[test]
fn test_minimal_procedure() {
let mod_type = &ModuleType::Procedure;
let mod_title = "Minimal procedure";
let options = minimal_options();
let procedure = Module::new(mod_type, mod_title, &options);

let pre_generated = include_str!("../data/generated/minimal-procedure.adoc");

assert_eq!(procedure.text, pre_generated);
}

/// Test that we generate the reference module that we expect.
#[test]
fn test_minimal_reference() {
let mod_type = &ModuleType::Reference;
let mod_title = "Minimal reference";
let options = minimal_options();
let reference = Module::new(mod_type, mod_title, &options);

let pre_generated =
include_str!("../data/generated/minimal-reference.adoc");

assert_eq!(reference.text, pre_generated);
}
}

0 comments on commit 1d6c3b7

Please sign in to comment.