git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chris Packham <judge.packham@gmail.com>
To: git@vger.kernel.org
Cc: jrnieder@gmail.com, gitster@pobox.com, j.sixt@viscovery.net,
	bebarino@gmail.com, Chris Packham <judge.packham@gmail.com>
Subject: [PATCHv3 2/2] tests for git alternate command
Date: Mon, 29 Mar 2010 14:39:41 -0700	[thread overview]
Message-ID: <1269898781-18564-3-git-send-email-judge.packham@gmail.com> (raw)
In-Reply-To: <1269898781-18564-1-git-send-email-judge.packham@gmail.com>

Signed-off-by: Chris Packham <judge.packham@gmail.com>
---
 t/t1430-alternate-cmd.sh |  154 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 154 insertions(+), 0 deletions(-)
 create mode 100644 t/t1430-alternate-cmd.sh

diff --git a/t/t1430-alternate-cmd.sh b/t/t1430-alternate-cmd.sh
new file mode 100644
index 0000000..ba27633
--- /dev/null
+++ b/t/t1430-alternate-cmd.sh
@@ -0,0 +1,154 @@
+#!/bin/sh
+#
+# Copyright (c) Chris Packham
+#
+
+test_description='Test of git alternate command'
+
+. ./test-lib.sh
+
+test_expect_success 'setup for rest of the test' '
+
+	mkdir -p base &&
+	(
+		cd base &&
+		git init &&
+		echo test > a.txt &&
+		echo test > b.txt &&
+		echo test > c.txt &&
+		git add *.txt &&
+		git commit -a -m "Initial Commit"
+	)
+	git clone base A &&
+	git clone A B &&
+	git clone A C &&
+	git clone A D
+	testbase=$(pwd)
+'
+
+test_expect_success 'can add alternate after clone' '
+
+	(
+		cd B &&
+		git alternate -a ../base/.git/objects &&
+
+		echo "$testbase/base/.git/objects" > expect &&
+		cp .git/objects/info/alternates actual   &&
+
+		test_cmp expect actual
+
+	)
+'
+
+test_expect_success 'add same alternate fails (absolute path)' '
+
+	(
+		cd B &&
+		test_must_fail git alternate -a $(pwd)/base/.git/objects
+	)
+'
+
+test_expect_success 'add same alternate fails (relative path)' '
+
+	(
+		cd B &&
+		test_must_fail git alternate -a ../base/.git/objects
+	)
+'
+
+test_expect_success 'can add multiple alternates' '
+
+	(
+		cd C &&
+		git alternate -a ../base/.git/objects &&
+		git alternate -a ../B/.git/objects &&
+
+		{
+			echo "$testbase/base/.git/objects"
+			echo "$testbase/B/.git/objects"
+		} > expect &&
+
+		cp .git/objects/info/alternates actual   &&
+
+		test_cmp expect actual
+	)
+'
+
+test_expect_success 'can add recursive alternate' '
+
+	(
+		cd D &&
+		git alternate -a ../C/.git/objects
+
+		echo "$testbase/C/.git/objects" > expect &&
+		cp .git/objects/info/alternates actual   &&
+
+		test_cmp expect actual
+	)
+'
+
+test_expect_success 'simple display' '
+
+	(
+		cd B &&
+		git alternate >actual &&
+		{
+			echo "Object store $testbase/base/.git/objects"
+			echo "    referenced via $testbase/B/.git"
+		} >expect &&
+
+		test_cmp expect actual
+	)
+'
+
+test_expect_success 'recursive display' '
+
+	(
+		cd D &&
+		git alternate -r >actual &&
+
+		{
+			echo "Object store $testbase/C/.git/objects"
+			echo "    referenced via $testbase/D/.git"
+			echo "Object store $testbase/base/.git/objects"
+			echo "    referenced via $testbase/C/.git"
+			echo "Object store $testbase/B/.git/objects"
+			echo "    referenced via $testbase/C/.git"
+			echo "Object store $testbase/base/.git/objects"
+			echo "    referenced via $testbase/B/.git"
+		} >expect &&
+
+		test_cmp expect actual
+	)
+'
+
+test_expect_success 'cannot delete unless --forced' '
+	(
+		cd C &&
+		test_must_fail git alternate -d "$testbase/B/.git/objects"
+	)
+'
+
+test_expect_success 'can delete one alternate' '
+	(
+		cd C &&
+		git alternate -f -d "$testbase/B/.git/objects" &&
+
+		echo "$testbase/base/.git/objects" > expect &&
+		cp .git/objects/info/alternates actual   &&
+
+		test_cmp expect actual
+	)
+'
+
+test_expect_success 'last alternate deleted removes file' '
+	(
+		cd C &&
+		git alternate -f -d "$testbase/base/.git/objects" &&
+
+		test ! -e .git/objects/info/alternates
+
+	)
+'
+
+test_done
-- 
1.7.0.3

      parent reply	other threads:[~2010-03-29 21:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-29 21:39 git alternate command Chris Packham
2010-03-29 21:39 ` [PATCHv3 1/2] Add " Chris Packham
2010-03-29 21:39 ` Chris Packham [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1269898781-18564-3-git-send-email-judge.packham@gmail.com \
    --to=judge.packham@gmail.com \
    --cc=bebarino@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=j.sixt@viscovery.net \
    --cc=jrnieder@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).