1use std::path::PathBuf;
2
3pub const WIT_CONTENT: &str = include_str!("../wit/vtx.wit");
4
5pub fn get_wit_path() -> PathBuf {
6 PathBuf::from(env!("CARGO_MANIFEST_DIR"))
7 .join("..")
8 .join("..")
9 .join("wit")
10 .join("vtx.wit")
11}
12
13#[cfg(test)]
14mod tests {
15 use super::*;
16 use std::fs;
17
18 #[test]
19 fn test_wit_file_path_resolution() {
20 let path = get_wit_path();
21
22 if !path.exists() {
23 panic!("Critical: WIT file not found at path: {:?}", path);
24 }
25
26 assert!(path.is_file(), "Path exists but is not a file: {:?}", path);
27
28 let content = fs::read_to_string(&path)
29 .unwrap_or_else(|_| panic!("Failed to read WIT file at: {:?}", path));
30
31 assert!(
32 content.contains("package vtx:api"),
33 "File content signature mismatch. Expected 'package vtx:api' header."
34 );
35 }
36
37 #[test]
38 fn test_embedded_content_validity() {
39 assert!(!WIT_CONTENT.is_empty(), "Embedded WIT_CONTENT is empty");
40 assert!(
41 WIT_CONTENT.contains("package vtx:api"),
42 "Embedded content signature mismatch"
43 );
44 }
45}