blob: 4c033c1f0a711138726458b994d7398d0d7204ad (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
# Back - An extremely simple git bug visualization system. Inspired by TVL's
# panettone.
#
# Copyright (C) 2025 Benedikt Peetz <benedikt.peetz@b-peetz.de>
# SPDX-License-Identifier: AGPL-3.0-or-later
#
# This file is part of Back.
#
# You should have received a copy of the License along with this program.
# If not, see <https://www.gnu.org/licenses/agpl.txt>.
{
pkgs,
module,
nixos-lib,
...
}:
nixos-lib.runTest {
hostPkgs = pkgs;
name = "back";
node = {
# Use the nixpkgs as constructed by the `nixpkgs.*` options
pkgs = null;
};
nodes = {
machine = {config, ...}: {
environment.systemPackages = [
pkgs.git
pkgs.git-bug
pkgs.curl
];
imports = [module];
vhack = {
back = {
enable = true;
user = "root";
group = "root";
settings = {
scan_path = "/srv/git/repositories";
project_list = "/srv/git/projects.list";
root_url = "https://issues.examplec.com";
};
};
};
};
};
testScript = {nodes, ...}:
/*
python
*/
''
start_all()
with subtest("Create git-bug issues in owner/repo"):
machine.succeed("${pkgs.writeShellScript "setup-git-repo" ''
set -ex
mkdir --parents /srv/git/repositories
cd /srv/git/repositories
echo "owner/repo" > /srv/git/projects.list
mkdir --parents owner/repo_base
cd owner/repo_base
git init
git bug user new --avatar "" --email "alice@machine.org" --name "alice" --non-interactive
git bug bug new \
--title "Some bug title" \
--message "A long description of the bug. Probably has some code segments, maybe even *markdown* mark_up_, <html> or other things" \
--non-interactive
git bug bug new \
--title "Second bug title" \
--message "" \
--non-interactive
git bug bug new \
--title "Third bug title" \
--message "" \
--non-interactive
git bug bug select "$(git bug bug --format plain | awk '{print $1}' | head -n 1)"
git bug bug comment new --message "Some <comment> message" --non-interactive
git bug bug comment new --message "Second comment message" --non-interactive
git bug bug label new "Test"
git bug bug label new "Test2"
cd /srv/git/repositories
git clone \
--bare \
--config 'remote.origin.fetch=+refs/bugs/*:refs/bugs/*' \
--config 'remote.origin.fetch=+refs/identities/*:refs/identities/*' \
./owner/repo_base ./owner/repo.git
''}")
with subtest("back machine starts"):
machine.wait_for_unit("back.service")
with subtest("client can access the machine"):
machine.succeed("${pkgs.writeShellScript "curl-back" ''
set -xe
curl --insecure --fail --show-error "http://127.0.0.1:8000/owner/repo/issues/?query=status:open" --output /root/issues.html
grep -- 'Second bug title' /root/issues.html
curl --insecure --fail --show-error "http://127.0.0.1:8000/" --output /root/repos.html
grep -- 'repo' /root/repos.html
grep -- "Unnamed repository; edit this file 'description' to name the repository." /root/repos.html
''} >&2")
machine.copy_from_vm("/root/issues.html", "");
machine.copy_from_vm("/root/repos.html", "");
'';
}
|