Add tests for templates and improve signatures
This commit is contained in:
parent
dd7c6c10fd
commit
e745ef3ad0
2 changed files with 42 additions and 5 deletions
|
|
@ -165,7 +165,7 @@ pub fn uwsgi_snippet<S: SocketSpec, STATIC: AsRef<Path>>(
|
|||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn static_snippet<S: AsRef<Path>>(static_path: S) -> String {
|
||||
pub fn static_snippet(static_path: impl AsRef<Path>) -> String {
|
||||
format!(
|
||||
"root {};
|
||||
try_files $uri $uri/ $uri.html =404;
|
||||
|
|
@ -175,7 +175,7 @@ pub fn static_snippet<S: AsRef<Path>>(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";
|
||||
}"#
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue