diff --git a/src/templates/nginx/server.rs b/src/templates/nginx/server.rs index 066777f..dd28bc4 100644 --- a/src/templates/nginx/server.rs +++ b/src/templates/nginx/server.rs @@ -165,7 +165,7 @@ pub fn uwsgi_snippet>( } #[must_use] -pub fn static_snippet>(static_path: S) -> String { +pub fn static_snippet(static_path: impl AsRef) -> String { format!( "root {}; try_files $uri $uri/ $uri.html =404; @@ -175,7 +175,7 @@ pub fn static_snippet>(static_path: S) -> String { } #[must_use] -pub fn dokuwiki_snippet() -> String { +pub const fn dokuwiki_snippet() -> &'static str { " location ~ /(data/|conf/|bin/|inc/|install.php) { deny all; } @@ -187,11 +187,11 @@ pub fn dokuwiki_snippet() -> String { rewrite ^/_detail/(.*) /lib/exe/detail.php?media=$1 last; rewrite ^/_export/([^/]+)/(.*) /doku.php?do=export_$1&id=$2 last; rewrite ^/(.*) /doku.php?id=$1&$args last; - }".into() + }" } #[must_use] -pub fn nextcloud_snippet() -> String { +pub const fn nextcloud_snippet() -> &'static str { " client_max_body_size 500M; @@ -241,5 +241,20 @@ pub fn nextcloud_snippet() -> String { access_log off; } " - .into() +} + +#[cfg(test)] +mod test { + use super::default_server; + #[test] + fn test_default_server() { + assert_eq!( + default_server("filename"), + r#"server { + listen 80 default_server; + listen [::]:80 default_server; + include "filename"; + }"# + ); + } } diff --git a/src/templates/php.rs b/src/templates/php.rs index 7bd7695..6e47e28 100644 --- a/src/templates/php.rs +++ b/src/templates/php.rs @@ -56,3 +56,25 @@ env[PATH] = /usr/local/bin:/usr/bin:/bin config ) } + +#[cfg(test)] +mod test { + use super::fpm_pool_config; + #[test] + fn test_fpm_pool_config() { + assert_eq!( + fpm_pool_config("user", "socket", &5.into()), + r"[user] + +user = user +group = www-data +listen = socket +listen.owner = www-data +pm = ondemand +catch_workers_output = yes +env[PATH] = /usr/local/bin:/usr/bin:/bin +pm.max_children = 5 +" + ); + } +}