summaryrefslogtreecommitdiff
path: root/tests/test-build-update-repo.sh
blob: be80b6131ee80562704cf4950e79fd838007a45f (plain)
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
#!/bin/bash
#
# Copyright © 2018 Endless Mobile, Inc.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
#
# Authors:
#  - Philip Withnall <withnall@endlessm.com>

set -euo pipefail

. $(dirname $0)/libtest.sh

skip_without_bwrap
skip_revokefs_without_fuse

echo "1..5"

# Configure a repository, then set a collection ID on it and check that the ID
# is saved in the config file.
setup_repo
install_repo

${FLATPAK} build-update-repo --collection-id=org.test.Collection repos/test >&2

assert_file_has_content repos/test/config '^collection-id=org\.test\.Collection$'

ok "1 update repo to add collection ID"

# Test that you’re not allowed to change the collection ID once it’s already set.
if ${FLATPAK} build-update-repo --collection-id=org.test.Collection2 repos/test &> build-update-repo-error-log; then
    assert_not_reached "flatpak build-update-repo should not set a collection ID when one is already set"
fi

assert_file_has_content repos/test/config '^collection-id=org\.test\.Collection$'
assert_not_file_has_content repos/test/config '^collection-id=org\.test\.Collection2$'

ok "2 collection ID cannot be changed"

${FLATPAK} build-update-repo --title="My little repo" repos/test >&2

assert_file_has_content repos/test/config '^title=My little repo$'

ok "can update repo title"

${FLATPAK} build-update-repo --redirect-url=http://no.where/ repos/test >&2

assert_file_has_content repos/test/config '^redirect-url=http://no\.where/$'

ok "can update redirect url"

${FLATPAK} build-update-repo --default-branch=no-such-branch repos/test >&2

assert_file_has_content repos/test/config '^default-branch=no-such-branch$'

ok "can update default branch"