Blob


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