ignition_core/webdev/
testing.rs1pub const TESTING_FILES: &[(&str, &str)] = &[
47 (
49 "ignition/script-python/resources/testing/runner/code.py",
50 include_str!(
51 "../../webdev/testing/ignition/script-python/resources/testing/runner/code.py"
52 ),
53 ),
54 (
55 "ignition/script-python/resources/testing/runner/resource.json",
56 include_str!(
57 "../../webdev/testing/ignition/script-python/resources/testing/runner/resource.json"
58 ),
59 ),
60 (
61 "ignition/script-python/resources/testing/assertions/code.py",
62 include_str!(
63 "../../webdev/testing/ignition/script-python/resources/testing/assertions/code.py"
64 ),
65 ),
66 (
67 "ignition/script-python/resources/testing/assertions/resource.json",
68 include_str!(
69 "../../webdev/testing/ignition/script-python/resources/testing/assertions/resource.json"
70 ),
71 ),
72 (
73 "ignition/script-python/resources/testing/decorators/code.py",
74 include_str!(
75 "../../webdev/testing/ignition/script-python/resources/testing/decorators/code.py"
76 ),
77 ),
78 (
79 "ignition/script-python/resources/testing/decorators/resource.json",
80 include_str!(
81 "../../webdev/testing/ignition/script-python/resources/testing/decorators/resource.json"
82 ),
83 ),
84 (
85 "ignition/script-python/resources/testing/helpers/code.py",
86 include_str!(
87 "../../webdev/testing/ignition/script-python/resources/testing/helpers/code.py"
88 ),
89 ),
90 (
91 "ignition/script-python/resources/testing/helpers/resource.json",
92 include_str!(
93 "../../webdev/testing/ignition/script-python/resources/testing/helpers/resource.json"
94 ),
95 ),
96 (
97 "ignition/script-python/resources/testing/reporter/code.py",
98 include_str!(
99 "../../webdev/testing/ignition/script-python/resources/testing/reporter/code.py"
100 ),
101 ),
102 (
103 "ignition/script-python/resources/testing/reporter/resource.json",
104 include_str!(
105 "../../webdev/testing/ignition/script-python/resources/testing/reporter/resource.json"
106 ),
107 ),
108 (
110 "ignition/script-python/resources/testing/__tests__/code.py",
111 include_str!(
112 "../../webdev/testing/ignition/script-python/resources/testing/__tests__/code.py"
113 ),
114 ),
115 (
116 "ignition/script-python/resources/testing/__tests__/resource.json",
117 include_str!(
118 "../../webdev/testing/ignition/script-python/resources/testing/__tests__/resource.json"
119 ),
120 ),
121 (
123 "com.inductiveautomation.webdev/resources/testing/run/doPost.py",
124 include_str!(
125 "../../webdev/testing/com.inductiveautomation.webdev/resources/testing/run/doPost.py"
126 ),
127 ),
128 (
129 "com.inductiveautomation.webdev/resources/testing/run/config.json",
130 include_str!(
131 "../../webdev/testing/com.inductiveautomation.webdev/resources/testing/run/config.json"
132 ),
133 ),
134 (
135 "com.inductiveautomation.webdev/resources/testing/run/resource.json",
136 include_str!(
137 "../../webdev/testing/com.inductiveautomation.webdev/resources/testing/run/resource.json"
138 ),
139 ),
140 (
141 "com.inductiveautomation.webdev/resources/testing/tags/doPost.py",
142 include_str!(
143 "../../webdev/testing/com.inductiveautomation.webdev/resources/testing/tags/doPost.py"
144 ),
145 ),
146 (
147 "com.inductiveautomation.webdev/resources/testing/tags/config.json",
148 include_str!(
149 "../../webdev/testing/com.inductiveautomation.webdev/resources/testing/tags/config.json"
150 ),
151 ),
152 (
153 "com.inductiveautomation.webdev/resources/testing/tags/resource.json",
154 include_str!(
155 "../../webdev/testing/com.inductiveautomation.webdev/resources/testing/tags/resource.json"
156 ),
157 ),
158];
159
160pub(crate) const PROJECT_MARKER: &str = "__IGN_CLI_PROJECT__";
162
163pub(crate) const PROJECT_MARKER_COUNT: usize = 2;
168
169pub const TESTING_ROUTES: &[&str] = &["run", "tags"];
172
173#[cfg(test)]
174mod tests {
175 use super::{PROJECT_MARKER, PROJECT_MARKER_COUNT, TESTING_FILES, TESTING_ROUTES};
176
177 #[test]
180 fn project_marker_count_is_pinned() {
181 let total: usize = TESTING_FILES
182 .iter()
183 .map(|(_, contents)| contents.matches(PROJECT_MARKER).count())
184 .sum();
185 assert_eq!(
186 total, PROJECT_MARKER_COUNT,
187 "a testing-bundle edit moved the __IGN_CLI_PROJECT__ marker count"
188 );
189 }
190
191 #[test]
194 fn bundle_manifest_is_pinned() {
195 assert_eq!(TESTING_FILES.len(), 18, "18 members: 12 script + 6 route");
196 for route in TESTING_ROUTES {
197 let prefix = format!("com.inductiveautomation.webdev/resources/testing/{route}/");
198 let files = TESTING_FILES
199 .iter()
200 .filter(|(name, _)| name.starts_with(&prefix))
201 .count();
202 assert_eq!(
203 files, 3,
204 "route {route} carries its 3 files (POST-only - the two-method config does not register on 8.3)"
205 );
206 }
207 for module in [
208 "runner",
209 "assertions",
210 "decorators",
211 "helpers",
212 "reporter",
213 "__tests__",
214 ] {
215 let path = format!("ignition/script-python/resources/testing/{module}/code.py");
216 assert!(
217 TESTING_FILES.iter().any(|(name, _)| *name == path),
218 "module {module} present"
219 );
220 }
221 }
222
223 #[test]
226 fn runner_carries_the_dual_layout_walk() {
227 let runner = TESTING_FILES
228 .iter()
229 .find(|(name, _)| *name == "ignition/script-python/resources/testing/runner/code.py")
230 .map(|(_, contents)| *contents)
231 .expect("runner present");
232 assert!(runner.contains("resources_path = File(script_path, \"resources\")"));
233 assert!(
234 runner.contains("base = resources_path if resources_path.exists() else script_path")
235 );
236 }
237}