From ba2688c78d1c6c7e092b6994b01e61fb1eaf34df Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 14 Oct 2018 14:32:02 +0200 Subject: util.http: Add tests for normalize_path --- spec/util_http_spec.lua | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'spec') diff --git a/spec/util_http_spec.lua b/spec/util_http_spec.lua index bacfcfb5..0f51a86c 100644 --- a/spec/util_http_spec.lua +++ b/spec/util_http_spec.lua @@ -61,4 +61,27 @@ describe("util.http", function() }); end); end); + + describe("normalize_path", function () + it("root path is always '/'", function () + assert.equal("/", http.normalize_path("/")); + assert.equal("/", http.normalize_path("")); + assert.equal("/", http.normalize_path("/", true)); + assert.equal("/", http.normalize_path("", true)); + end); + + it("works", function () + assert.equal("/foo", http.normalize_path("foo")); + assert.equal("/foo", http.normalize_path("/foo")); + assert.equal("/foo", http.normalize_path("foo/")); + assert.equal("/foo", http.normalize_path("/foo/")); + end); + + it("is_dir works", function () + assert.equal("/foo/", http.normalize_path("foo", true)); + assert.equal("/foo/", http.normalize_path("/foo", true)); + assert.equal("/foo/", http.normalize_path("foo/", true)); + assert.equal("/foo/", http.normalize_path("/foo/", true)); + end); + end); end); -- cgit v1.2.3