~zethra/stargazer

7cc5ab0f2e2d5fbcf304a9f6988394f48425aa32 — Ben Aaron Goldberg 14 days ago 8cf298d
tests: added directory listing test
1 files changed, 36 insertions(+), 0 deletions(-)

M scripts/gemini-diagnostics
M scripts/gemini-diagnostics => scripts/gemini-diagnostics +36 -0
@@ 843,6 843,42 @@ class CharsetParam(BaseCheck):
        log("Meta should be text/plain; charset=ascii")
        self.log_test(f"{response.meta!r}", response.meta == "text/plain; charset=ascii")

class DirectoryListing(BaseCheck):
    """Check that directory listing works and is in order"""

    def check(self):
        url = "gemini://localhost/list/\r\n"
        response = self.make_request(url)

        log("Status should return code 20")
        self.log_test(f"{response.status!r}", response.status == "20")
        
        correct_body = """
=> ..
=>sub1/ sub1
=>sub2/ sub2
=>%E3%81%93%E3%82%93%E3%81%AB%E3%81%A1%E3%81%AF%E4%B8%96%E7%95%8C%EF%BC%81%2Etxt こんにちは世界!.txt
=>1%2Etxt 1.txt
=>10%2Etxt 10.txt
=>2%2Etxt 2.txt
=>3%2Etxt 3.txt
=>4%2Etxt 4.txt
=>5%2Etxt 5.txt
=>6%2Etxt 6.txt
=>7%2Etxt 7.txt
=>8%2Etxt 8.txt
=>9%2Etxt 9.txt
=>hello%2530%23%5E%5C%26%23%24%25%5F%2B%5F%21%21%7E%7E%7E%60%60%60%2Etxt hello%30#^\&#$%_+_!!~~~```.txt
        """.strip()
        body = response.body.strip()
        log("Body should match")
        self.log_test("", body == correct_body)
        if body != correct_body:
            print("Got:")
            print(body)
            print("\nDiff:")
            print(show_diff(body, correct_body))

# noinspection PyTypeChecker
# fmt: off
parser = argparse.ArgumentParser(