diff --git a/posts/2025-06-22-test-nginx-conf-directives.md b/posts/2025-06-22-test-nginx-conf-directives.md index 7cdbbcc..940dab4 100644 --- a/posts/2025-06-22-test-nginx-conf-directives.md +++ b/posts/2025-06-22-test-nginx-conf-directives.md @@ -372,19 +372,19 @@ Add a spec: ```moonscript describe "https://git.domain.abc", -> - it "reverse-proxies request to a gitea unix socket", -> - Path = require "sitegen.path" - socket_fname = "unixstreamsrvr.moon" - socket_dir = "/run/gitea" - socket_owner = "nobody" - basepath = Path.basepath debug.getinfo(1).short_src + it "reverse-proxy's request to a gitea unix socket", -> + socket = fname: "unixstreamsrvr.moon", dir: "/run/gitea", owner: "nobody" + basepath = debug.getinfo(1).short_src\match"^(.*)/[^/]*$" or "." + seconds = 0.1 - Path.exec "install", "-o", socket_owner, "-d", socket_dir + os.execute "install -o #{socket.owner} -d #{socket.dir}" cmd = "su -s /bin/bash -c 'moon %s' %s" - server = io.popen cmd\format Path.join(basepath, socket_fname), socket_owner - Path.exec "sleep", "0.1" - result = Path.read_exec "find", socket_dir, "-type", "s", "-ls" - assert.truthy result\match "nobody%s+nogroup.+" .. Path.join(socket_dir, "gitea.socket") + server = io.popen cmd\format "#{basepath}/#{socket.fname}", socket.owner + os.execute "sleep #{seconds}" + f = io.popen "find #{socket.dir} -type s -ls", "r" + result = with f\read "*a" + f\close! + assert.truthy result\match "nobody%s+nogroup.+#{socket.dir}/gitea.socket" req "https://git.domain.abc"