Re: [PATCH v1 09/11] t: add tests for restore

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 3/8/19 11:16 AM, Nguyễn Thái Ngọc Duy wrote:
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx>
> ---
>  t/lib-patch-mode.sh               |  12 ++++
>  t/t2070-restore.sh (new +x)       |  77 ++++++++++++++++++++++
>  t/t2071-restore-patch.sh (new +x) | 105 ++++++++++++++++++++++++++++++
>  3 files changed, 194 insertions(+)
> 
> diff --git a/t/t2070-restore.sh b/t/t2070-restore.sh
> new file mode 100755
> index 0000000000..df91bf54bc
> --- /dev/null
> +++ b/t/t2070-restore.sh
> @@ -0,0 +1,77 @@
> +#!/bin/sh
> +
> +test_description='restore basic functionality'
> +
> +. ./test-lib.sh
> +
> +test_expect_success 'setup' '
> +	test_commit first &&
> +	echo first-and-a-half >>first.t &&
> +	git add first.t &&
> +	test_commit second &&
> +	echo one >one &&
> +	echo two >two &&
> +	echo untracked >untracked &&
> +	echo ignored >ignored &&
> +	echo /ignored >.gitignore &&
> +	git add one two .gitignore &&
> +	git update-ref refs/heads/one master
> +'
> +

[snip]

> +
> +test_expect_success 'restore a file, ignoring branch of same name' '
> +	cat one >expected &&
> +	echo dirty >>one &&
> +	git restore one &&
> +	test_cmp expected one
> +'
> +

Branch 'one' has been created by update-ref invocation in the setup, OK.

> +test_expect_success 'restore a file on worktree from another branch' '
> +	test_when_finished git reset --hard &&
> +	git cat-file blob first:./first.t >expected &&
> +	git restore --source=first first.t &&
> +	test_cmp expected first.t &&
> +	git cat-file blob HEAD:./first.t >expected &&
> +	git show :first.t >actual &&
> +	test_cmp expected actual
> +'

Test description reads "from another branch". However "first", created by
test_commit invocation is a tag. Maybe description should read "from another
ref"? Same applies to other tests which utilize "first".

> +
> +test_expect_success 'restore a file in the index from another branch' '
> +	test_when_finished git reset --hard &&
> +	git cat-file blob first:./first.t >expected &&
> +	git restore --source=first --index first.t &&
> +	git show :first.t >actual &&
> +	test_cmp expected actual &&
> +	git cat-file blob HEAD:./first.t >expected &&
> +	test_cmp expected first.t
> +'
> +
> +test_expect_success 'restore a file in both the index and worktree from another branch' '
> +	test_when_finished git reset --hard &&
> +	git cat-file blob first:./first.t >expected &&
> +	git restore --source=first --index --worktree first.t &&
> +	git show :first.t >actual &&
> +	test_cmp expected actual &&
> +	test_cmp expected first.t
> +'
> +
> +test_expect_success 'restore --index uses HEAD as source' '
> +	test_when_finished git reset --hard &&
> +	git cat-file blob :./first.t >expected &&
> +	echo index-dirty >>first.t &&
> +	git add first.t &&
> +	git restore --index first.t &&
> +	git cat-file blob :./first.t >actual &&
> +	test_cmp expected actual
> +'
> +
> +test_done


--
Best regards, Andrei R.



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux