2011-10-28 18:25:36 +04:00
#!/bin/bash
#
# Copyright (C) 2011 Colin Walters <walters@verbum.org>
#
2011-11-10 22:17:04 +04:00
# 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.
2011-10-28 18:25:36 +04:00
#
2011-11-10 22:17:04 +04:00
# This library is distributed in the hope that it will be useful,
2011-10-28 18:25:36 +04:00
# but WITHOUT ANY WARRANTY; without even the implied warranty of
2011-11-10 22:17:04 +04:00
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
2011-10-28 18:25:36 +04:00
#
2011-11-10 22:17:04 +04:00
# 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.
2011-10-28 18:25:36 +04:00
2016-01-27 19:44:10 +03:00
set -euo pipefail
2011-10-28 18:25:36 +04:00
2013-05-01 23:26:21 +04:00
. $( dirname $0 ) /libtest.sh
2011-10-28 18:25:36 +04:00
2016-03-02 18:28:04 +03:00
echo '1..13'
2011-10-28 18:25:36 +04:00
2012-09-15 20:44:57 +04:00
setup_test_repository "bare"
2011-11-04 07:08:28 +04:00
$OSTREE remote add origin http://example.com/ostree/gnome
2014-12-16 00:21:15 +03:00
$OSTREE remote show-url origin >/dev/null
2011-10-28 18:25:36 +04:00
echo "ok config"
2013-12-25 23:17:36 +04:00
$OSTREE remote add --no-gpg-verify another http://another.com/repo
2014-12-16 00:21:15 +03:00
$OSTREE remote show-url another >/dev/null
2013-12-25 23:17:36 +04:00
echo "ok remote no gpg-verify"
2014-10-17 19:47:01 +04:00
2014-12-16 00:21:15 +03:00
if $OSTREE remote add --no-gpg-verify another http://another.example.com/anotherrepo 2>err.txt; then
assert_not_reached "Adding duplicate remote unexpectedly succeeded"
fi
echo "ok"
$OSTREE remote add --if-not-exists --no-gpg-verify another http://another.example.com/anotherrepo
$OSTREE remote show-url another >/dev/null
echo "ok"
$OSTREE remote add --if-not-exists --no-gpg-verify another-noexist http://another-noexist.example.com/anotherrepo
$OSTREE remote show-url another-noexist >/dev/null
echo "ok"
2014-12-16 18:41:34 +03:00
$OSTREE remote list > list.txt
assert_file_has_content list.txt "origin"
assert_file_has_content list.txt "another"
assert_file_has_content list.txt "another-noexist"
assert_not_file_has_content list.txt "http://example.com/ostree/gnome"
assert_not_file_has_content list.txt "http://another.com/repo"
assert_not_file_has_content list.txt "http://another-noexist.example.com/anotherrepo"
echo "ok remote list"
$OSTREE remote list --show-urls > list.txt
assert_file_has_content list.txt "origin"
assert_file_has_content list.txt "another"
assert_file_has_content list.txt "another-noexist"
assert_file_has_content list.txt "http://example.com/ostree/gnome"
assert_file_has_content list.txt "http://another.com/repo"
assert_file_has_content list.txt "http://another-noexist.example.com/anotherrepo"
echo "ok remote list with urls"
2014-10-17 19:47:01 +04:00
$OSTREE remote delete another
echo "ok remote delete"
if $OSTREE remote delete nosuchremote 2>err.txt; then
assert_not_reached "Deleting remote unexpectedly succeeded"
fi
assert_file_has_content err.txt "error: "
2014-12-16 00:21:15 +03:00
$OSTREE remote delete --if-exists nosuchremote
echo "ok"
2014-10-17 19:47:01 +04:00
2014-12-16 00:21:15 +03:00
if $OSTREE remote show-url nosuchremote 2>/dev/null; then
assert_not_reached "Deleting remote unexpectedly failed"
fi
echo "ok"
$OSTREE remote delete --if-exists origin
echo "ok"
if $OSTREE remote show-url origin 2>/dev/null; then
assert_not_reached "Deleting remote unexpectedly failed"
fi
echo "ok"
2014-12-16 18:41:34 +03:00
$OSTREE remote list > list.txt
assert_not_file_has_content list.txt "origin"
# Can't grep for 'another' because of 'another-noexist'
assert_file_has_content list.txt "another-noexist"
echo "ok remote list remaining"