Skip to content

Commit f7ebfdd

Browse files
committed
Add test for sys functionality.
1 parent ea64b9b commit f7ebfdd

File tree

1 file changed

+21
-0
lines changed
  • rust/src/nasl/builtin/sys

1 file changed

+21
-0
lines changed

rust/src/nasl/builtin/sys/mod.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,4 +127,25 @@ mod tests {
127127
t.ok(r#"pread("basename", "/a/b/c");"#, "c\n");
128128
t.async_verify().await;
129129
}
130+
131+
#[tokio::test]
132+
async fn find_in_path() {
133+
let mut t = TestBuilder::default();
134+
t.ok(r#"find_in_path("basename");"#, true);
135+
// Cannot think of a way to construct a command name here
136+
// that is very unlikely to exist without it sounding ridiculous
137+
t.ok(r#"find_in_path("foobarbaz");"#, false);
138+
t.async_verify().await;
139+
}
140+
141+
#[tokio::test]
142+
async fn write_read_to_tmpdir() {
143+
let mut t = TestBuilder::default();
144+
t.run(r#"path = get_tmp_dir();"#);
145+
t.run(r#"file = path + "/write_read_to_tmpdir";"#);
146+
t.ok(r#"fwrite(file: file, data: "foo");"#, 3);
147+
t.ok(r#"fread(file);"#, "foo");
148+
t.ok(r#"file_stat(file);"#, 3);
149+
t.async_verify().await;
150+
}
130151
}

0 commit comments

Comments
 (0)