{ pkgs, self }: let # python = pkgs.python310.withPackages (ps: with ps; [ requests aiokafka ]); rebuildableTest = import ./rebuildableTest.nix pkgs; in rebuildableTest { name = "test-mastodon-garage"; # skipLint = true; # skipTypeCheck = true; nodes = { server = { imports = [ self.nixosModules.garage self.nixosModules.mastodon ]; environment.systemPackages = with pkgs; [ toot ]; }; }; testScript = '' import re import time server.start() with subtest("Mastodon starts"): server.wait_for_unit("mastodon-web.service") # make sure mastodon is fully up and running before we interact with it time.sleep(180) with subtest("Account creation"): account_creation_output = server.succeed("mastodon-tootctl accounts create test --email test@test.com --confirmed --approve") password_re = re.compile('New password: (.*)') password_match = password_re.match(account_creation_output) assert password_match is not None password = password_match.groups()[0] with subtest("Log in with toot"): # toot doesn't provide a way to just specify our login details as arguments, so we have to pretend we're typing them in at the prompt server.send_chars("toot login_ctl\n") time.sleep(0.2) # Enter instance URL server.send_chars("http://mastodon.localhost:55001\n") time.sleep(0.2) # Email server.send_chars("test@test.com\n") time.sleep(0.2) # Password server.send_chars(password + "\n") with subtest("Post an image"): server.succeed("toot post --media ${./fediversity.png}") # TODO: I don't think there's a good way to test for whether the image visually shows up. # we can test for CORS headers using curl / xh # or **maybe** somehow read the javascript console? ''; }