Compare commits
No commits in common. "101a324a2ee9ed4ce8c172a7c5b7bb8cc4d6a350" and "cc7d00af4554e5e59c26a0c425a8a74d961c08aa" have entirely different histories.
101a324a2e
...
cc7d00af45
2 changed files with 6 additions and 171 deletions
|
|
@ -149,7 +149,6 @@ User=$CONTAINER_NAME
|
||||||
Group=$CONTAINER_NAME
|
Group=$CONTAINER_NAME
|
||||||
ExecStart=$BIN_PATH/forgejo-runner daemon
|
ExecStart=$BIN_PATH/forgejo-runner daemon
|
||||||
Restart=always
|
Restart=always
|
||||||
RestartSec=5
|
|
||||||
StandardOutput=append:/opt/gbo/logs/output.log
|
StandardOutput=append:/opt/gbo/logs/output.log
|
||||||
StandardError=append:/opt/gbo/logs/error.log
|
StandardError=append:/opt/gbo/logs/error.log
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,7 @@ pub fn first_keyword(engine: &mut Engine) {
|
||||||
let input_str = input_string.to_string();
|
let input_str = input_string.to_string();
|
||||||
|
|
||||||
// Extract first word by splitting on whitespace
|
// Extract first word by splitting on whitespace
|
||||||
let first_word = input_str
|
let first_word = input_str.split_whitespace()
|
||||||
.split_whitespace()
|
|
||||||
.next()
|
.next()
|
||||||
.unwrap_or("")
|
.unwrap_or("")
|
||||||
.to_string();
|
.to_string();
|
||||||
|
|
@ -20,166 +19,3 @@ pub fn first_keyword(engine: &mut Engine) {
|
||||||
})
|
})
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use super::*;
|
|
||||||
use rhai::{Dynamic, Engine};
|
|
||||||
|
|
||||||
fn setup_engine() -> Engine {
|
|
||||||
let mut engine = Engine::new();
|
|
||||||
first_keyword(&mut engine);
|
|
||||||
engine
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_first_keyword_basic() {
|
|
||||||
let engine = setup_engine();
|
|
||||||
|
|
||||||
let result = engine
|
|
||||||
.eval::<String>(
|
|
||||||
r#"
|
|
||||||
FIRST "hello world"
|
|
||||||
"#,
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
assert_eq!(result, "hello");
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_first_keyword_single_word() {
|
|
||||||
let engine = setup_engine();
|
|
||||||
|
|
||||||
let result = engine
|
|
||||||
.eval::<String>(
|
|
||||||
r#"
|
|
||||||
FIRST "single"
|
|
||||||
"#,
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
assert_eq!(result, "single");
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_first_keyword_multiple_spaces() {
|
|
||||||
let engine = setup_engine();
|
|
||||||
|
|
||||||
let result = engine
|
|
||||||
.eval::<String>(
|
|
||||||
r#"
|
|
||||||
FIRST " leading spaces"
|
|
||||||
"#,
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
assert_eq!(result, "leading");
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_first_keyword_empty_string() {
|
|
||||||
let engine = setup_engine();
|
|
||||||
|
|
||||||
let result = engine
|
|
||||||
.eval::<String>(
|
|
||||||
r#"
|
|
||||||
FIRST ""
|
|
||||||
"#,
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
assert_eq!(result, "");
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_first_keyword_whitespace_only() {
|
|
||||||
let engine = setup_engine();
|
|
||||||
|
|
||||||
let result = engine
|
|
||||||
.eval::<String>(
|
|
||||||
r#"
|
|
||||||
FIRST " "
|
|
||||||
"#,
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
assert_eq!(result, "");
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_first_keyword_with_tabs() {
|
|
||||||
let engine = setup_engine();
|
|
||||||
|
|
||||||
let result = engine
|
|
||||||
.eval::<String>(
|
|
||||||
r#"
|
|
||||||
FIRST " tab separated words"
|
|
||||||
"#,
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
assert_eq!(result, "tab");
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_first_keyword_with_variable() {
|
|
||||||
let engine = setup_engine();
|
|
||||||
|
|
||||||
let result = engine
|
|
||||||
.eval::<String>(
|
|
||||||
r#"
|
|
||||||
let text = "variable test";
|
|
||||||
FIRST text
|
|
||||||
"#,
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
assert_eq!(result, "variable");
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_first_keyword_with_expression() {
|
|
||||||
let engine = setup_engine();
|
|
||||||
|
|
||||||
let result = engine
|
|
||||||
.eval::<String>(
|
|
||||||
r#"
|
|
||||||
FIRST "one two " + "three four"
|
|
||||||
"#,
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
assert_eq!(result, "one");
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_first_keyword_mixed_whitespace() {
|
|
||||||
let engine = setup_engine();
|
|
||||||
|
|
||||||
let result = engine
|
|
||||||
.eval::<String>(
|
|
||||||
r#"
|
|
||||||
FIRST " multiple spaces between words "
|
|
||||||
"#,
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
assert_eq!(result, "multiple");
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_first_keyword_special_characters() {
|
|
||||||
let engine = setup_engine();
|
|
||||||
|
|
||||||
let result = engine
|
|
||||||
.eval::<String>(
|
|
||||||
r#"
|
|
||||||
FIRST "hello-world example"
|
|
||||||
"#,
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
assert_eq!(result, "hello-world");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue