3 e9424ba1 2022-09-20 thomas # Copyright (c) 2022 Mark Jamsek <mark@jamsek.dev>
5 e9424ba1 2022-09-20 thomas # Permission to use, copy, modify, and distribute this software for any
6 e9424ba1 2022-09-20 thomas # purpose with or without fee is hereby granted, provided that the above
7 e9424ba1 2022-09-20 thomas # copyright notice and this permission notice appear in all copies.
9 e9424ba1 2022-09-20 thomas # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 e9424ba1 2022-09-20 thomas # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 e9424ba1 2022-09-20 thomas # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 e9424ba1 2022-09-20 thomas # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 e9424ba1 2022-09-20 thomas # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 e9424ba1 2022-09-20 thomas # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 e9424ba1 2022-09-20 thomas # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 e9424ba1 2022-09-20 thomas . ./common.sh
19 e9424ba1 2022-09-20 thomas test_init_basic() {
20 e9424ba1 2022-09-20 thomas local testname=init_basic
21 e9424ba1 2022-09-20 thomas local testroot=`mktemp -d "$GOT_TEST_ROOT/got-test-$testname-XXXXXXXX"`
22 e9424ba1 2022-09-20 thomas local headref=main
24 e9424ba1 2022-09-20 thomas gotadmin init $testroot/repo
26 e9424ba1 2022-09-20 thomas local git_head=`(cd $testroot/repo && git symbolic-ref HEAD)`
27 e9424ba1 2022-09-20 thomas echo $git_head > $testroot/content
28 e9424ba1 2022-09-20 thomas echo refs/heads/$headref > $testroot/content.expected
29 e9424ba1 2022-09-20 thomas cmp -s $testroot/content.expected $testroot/content
31 e9424ba1 2022-09-20 thomas if [ $ret -ne 0 ]; then
32 e9424ba1 2022-09-20 thomas echo "fail"
33 e9424ba1 2022-09-20 thomas diff -u $testroot/content.expected $testroot/content
35 e9424ba1 2022-09-20 thomas test_done "$testroot" "$ret"
38 e9424ba1 2022-09-20 thomas test_init_specified_head() {
39 e9424ba1 2022-09-20 thomas local testname=init_specified_head
40 e9424ba1 2022-09-20 thomas local testroot=`mktemp -d "$GOT_TEST_ROOT/got-test-$testname-XXXXXXXX"`
41 e9424ba1 2022-09-20 thomas local headref=trunk
43 e9424ba1 2022-09-20 thomas gotadmin init -b $headref $testroot/repo
45 e9424ba1 2022-09-20 thomas local git_head=`(cd $testroot/repo && git symbolic-ref HEAD)`
46 e9424ba1 2022-09-20 thomas echo refs/heads/$headref > $testroot/content.expected
47 e9424ba1 2022-09-20 thomas echo $git_head > $testroot/content
48 e9424ba1 2022-09-20 thomas cmp -s $testroot/content.expected $testroot/content
50 e9424ba1 2022-09-20 thomas if [ $ret -ne 0 ]; then
51 e9424ba1 2022-09-20 thomas echo "fail"
52 e9424ba1 2022-09-20 thomas diff -u $testroot/content.expected $testroot/content
54 e9424ba1 2022-09-20 thomas test_done "$testroot" "$ret"
57 e9424ba1 2022-09-20 thomas test_parseargs "$@"
58 e9424ba1 2022-09-20 thomas run_test test_init_basic
59 e9424ba1 2022-09-20 thomas run_test test_init_specified_head