pub const TESTING_FILES: &[(&str, &str)] = &[
(
"ignition/script-python/resources/testing/runner/code.py",
include_str!(
"../../webdev/testing/ignition/script-python/resources/testing/runner/code.py"
),
),
(
"ignition/script-python/resources/testing/runner/resource.json",
include_str!(
"../../webdev/testing/ignition/script-python/resources/testing/runner/resource.json"
),
),
(
"ignition/script-python/resources/testing/assertions/code.py",
include_str!(
"../../webdev/testing/ignition/script-python/resources/testing/assertions/code.py"
),
),
(
"ignition/script-python/resources/testing/assertions/resource.json",
include_str!(
"../../webdev/testing/ignition/script-python/resources/testing/assertions/resource.json"
),
),
(
"ignition/script-python/resources/testing/decorators/code.py",
include_str!(
"../../webdev/testing/ignition/script-python/resources/testing/decorators/code.py"
),
),
(
"ignition/script-python/resources/testing/decorators/resource.json",
include_str!(
"../../webdev/testing/ignition/script-python/resources/testing/decorators/resource.json"
),
),
(
"ignition/script-python/resources/testing/helpers/code.py",
include_str!(
"../../webdev/testing/ignition/script-python/resources/testing/helpers/code.py"
),
),
(
"ignition/script-python/resources/testing/helpers/resource.json",
include_str!(
"../../webdev/testing/ignition/script-python/resources/testing/helpers/resource.json"
),
),
(
"ignition/script-python/resources/testing/reporter/code.py",
include_str!(
"../../webdev/testing/ignition/script-python/resources/testing/reporter/code.py"
),
),
(
"ignition/script-python/resources/testing/reporter/resource.json",
include_str!(
"../../webdev/testing/ignition/script-python/resources/testing/reporter/resource.json"
),
),
(
"ignition/script-python/resources/testing/__tests__/code.py",
include_str!(
"../../webdev/testing/ignition/script-python/resources/testing/__tests__/code.py"
),
),
(
"ignition/script-python/resources/testing/__tests__/resource.json",
include_str!(
"../../webdev/testing/ignition/script-python/resources/testing/__tests__/resource.json"
),
),
(
"com.inductiveautomation.webdev/resources/testing/run/doPost.py",
include_str!(
"../../webdev/testing/com.inductiveautomation.webdev/resources/testing/run/doPost.py"
),
),
(
"com.inductiveautomation.webdev/resources/testing/run/config.json",
include_str!(
"../../webdev/testing/com.inductiveautomation.webdev/resources/testing/run/config.json"
),
),
(
"com.inductiveautomation.webdev/resources/testing/run/resource.json",
include_str!(
"../../webdev/testing/com.inductiveautomation.webdev/resources/testing/run/resource.json"
),
),
(
"com.inductiveautomation.webdev/resources/testing/tags/doPost.py",
include_str!(
"../../webdev/testing/com.inductiveautomation.webdev/resources/testing/tags/doPost.py"
),
),
(
"com.inductiveautomation.webdev/resources/testing/tags/config.json",
include_str!(
"../../webdev/testing/com.inductiveautomation.webdev/resources/testing/tags/config.json"
),
),
(
"com.inductiveautomation.webdev/resources/testing/tags/resource.json",
include_str!(
"../../webdev/testing/com.inductiveautomation.webdev/resources/testing/tags/resource.json"
),
),
];
pub(crate) const PROJECT_MARKER: &str = "__IGN_CLI_PROJECT__";
pub(crate) const PROJECT_MARKER_COUNT: usize = 2;
pub const TESTING_ROUTES: &[&str] = &["run", "tags"];
#[cfg(test)]
mod tests {
use super::{PROJECT_MARKER, PROJECT_MARKER_COUNT, TESTING_FILES, TESTING_ROUTES};
#[test]
fn project_marker_count_is_pinned() {
let total: usize = TESTING_FILES
.iter()
.map(|(_, contents)| contents.matches(PROJECT_MARKER).count())
.sum();
assert_eq!(
total, PROJECT_MARKER_COUNT,
"a testing-bundle edit moved the __IGN_CLI_PROJECT__ marker count"
);
}
#[test]
fn bundle_manifest_is_pinned() {
assert_eq!(TESTING_FILES.len(), 18, "18 members: 12 script + 6 route");
for route in TESTING_ROUTES {
let prefix = format!("com.inductiveautomation.webdev/resources/testing/{route}/");
let files = TESTING_FILES
.iter()
.filter(|(name, _)| name.starts_with(&prefix))
.count();
assert_eq!(
files, 3,
"route {route} carries its 3 files (POST-only - the two-method config does not register on 8.3)"
);
}
for module in [
"runner",
"assertions",
"decorators",
"helpers",
"reporter",
"__tests__",
] {
let path = format!("ignition/script-python/resources/testing/{module}/code.py");
assert!(
TESTING_FILES.iter().any(|(name, _)| *name == path),
"module {module} present"
);
}
}
#[test]
fn runner_carries_the_dual_layout_walk() {
let runner = TESTING_FILES
.iter()
.find(|(name, _)| *name == "ignition/script-python/resources/testing/runner/code.py")
.map(|(_, contents)| *contents)
.expect("runner present");
assert!(runner.contains("resources_path = File(script_path, \"resources\")"));
assert!(
runner.contains("base = resources_path if resources_path.exists() else script_path")
);
}
}