Skip to content

Commit 7fb4edc

Browse files
add test for sparse clone
Signed-off-by: Casey Braithwaite <casey.braithwaite@capgemini.com>
1 parent 24b50e3 commit 7fb4edc

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

test/get.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,23 @@ it_can_get_from_url_at_override_branch() {
9191
test "$(git -C $dest rev-parse HEAD)" = $ref
9292
}
9393

94+
it_can_get_from_url_with_sparse_paths() {
95+
local repo=$(init_repo)
96+
local ref1=$(make_commit_to_file $repo file-a)
97+
local ref2=$(make_commit_to_file $repo file-b)
98+
local dest=$TMPDIR/destination
99+
local sparse_paths="file-a"
100+
101+
get_uri_with_sparse $repo $dest $sparse_paths | jq -e "
102+
.version == {ref: $(echo $ref2 | jq -R .)}
103+
"
104+
105+
test -e $dest/file-a
106+
test ! -e $dest/file-b
107+
108+
test "$(git -C $dest rev-parse HEAD)" = $ref2
109+
}
110+
94111
it_omits_empty_branch_in_metadata() {
95112
local repo=$(init_repo)
96113
local ref1=$(make_commit_to_branch $repo branch-a)
@@ -916,6 +933,7 @@ run it_can_get_from_url_at_ref
916933
run it_can_get_from_url_at_branch
917934
run it_can_get_from_url_only_single_branch
918935
run it_can_get_from_url_at_override_branch
936+
run it_can_get_from_url_with_sparse_paths
919937
run it_omits_empty_branch_in_metadata
920938
run it_returns_branch_in_metadata
921939
run it_omits_empty_tags_in_metadata

test/helpers.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,6 +1056,18 @@ get_uri_with_custom_timestamp() {
10561056
}" | ${resource_dir}/in "$2" | tee /dev/stderr
10571057
}
10581058

1059+
get_uri_with_sparse() {
1060+
jq -n "{
1061+
source: {
1062+
uri: $(echo $1 | jq -R .),
1063+
sparse_paths: $(echo "$@" | jq -R '. | split(" ")')
1064+
},
1065+
params: {
1066+
short_ref_format: \"test-%s\"
1067+
}
1068+
}" | ${resource_dir}/in "$2" | tee /dev/stderr
1069+
}
1070+
10591071
put_uri() {
10601072
jq -n "{
10611073
source: {

0 commit comments

Comments
 (0)