mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-20 12:43:52 +00:00
4f0dadbf38
After final improvements to the official formatter implementation, this commit now performs the first treewide reformat of Nix files using it. This is part of the implementation of RFC 166. Only "inactive" files are reformatted, meaning only files that aren't being touched by any PR with activity in the past 2 months. This is to avoid conflicts for PRs that might soon be merged. Later we can do a full treewide reformat to get the rest, which should not cause as many conflicts. A CI check has already been running for some time to ensure that new and already-formatted files are formatted, so the files being reformatted here should also stay formatted. This commit was automatically created and can be verified using nix-builda08b3a4d19
.tar.gz \ --argstr baseRevb32a094368
result/bin/apply-formatting $NIXPKGS_PATH
76 lines
2.0 KiB
Nix
76 lines
2.0 KiB
Nix
import ./make-test-python.nix (
|
|
{ pkgs, ... }:
|
|
let
|
|
ankiSyncTest = pkgs.writeScript "anki-sync-test.py" ''
|
|
#!${pkgs.python3}/bin/python
|
|
|
|
import sys
|
|
|
|
# get site paths from anki itself
|
|
from runpy import run_path
|
|
run_path("${pkgs.anki}/bin/.anki-wrapped")
|
|
import anki
|
|
|
|
col = anki.collection.Collection('test_collection')
|
|
endpoint = 'http://localhost:27701'
|
|
|
|
# Sanity check: verify bad login fails
|
|
try:
|
|
col.sync_login('baduser', 'badpass', endpoint)
|
|
print("bad user login worked?!")
|
|
sys.exit(1)
|
|
except anki.errors.SyncError:
|
|
pass
|
|
|
|
# test logging in to users
|
|
col.sync_login('user', 'password', endpoint)
|
|
col.sync_login('passfileuser', 'passfilepassword', endpoint)
|
|
|
|
# Test actual sync. login apparently doesn't remember the endpoint...
|
|
login = col.sync_login('user', 'password', endpoint)
|
|
login.endpoint = endpoint
|
|
sync = col.sync_collection(login, False)
|
|
assert sync.required == sync.NO_CHANGES
|
|
# TODO: create an archive with server content including a test card
|
|
# and check we got it?
|
|
'';
|
|
testPasswordFile = pkgs.writeText "anki-password" "passfilepassword";
|
|
in
|
|
{
|
|
name = "anki-sync-server";
|
|
meta = with pkgs.lib.maintainers; {
|
|
maintainers = [ martinetd ];
|
|
};
|
|
|
|
nodes.machine =
|
|
{ pkgs, ... }:
|
|
{
|
|
services.anki-sync-server = {
|
|
enable = true;
|
|
users = [
|
|
{
|
|
username = "user";
|
|
password = "password";
|
|
}
|
|
{
|
|
username = "passfileuser";
|
|
passwordFile = testPasswordFile;
|
|
}
|
|
];
|
|
};
|
|
};
|
|
|
|
testScript = ''
|
|
start_all()
|
|
|
|
with subtest("Server starts successfully"):
|
|
# service won't start without users
|
|
machine.wait_for_unit("anki-sync-server.service")
|
|
machine.wait_for_open_port(27701)
|
|
|
|
with subtest("Can sync"):
|
|
machine.succeed("${ankiSyncTest}")
|
|
'';
|
|
}
|
|
)
|