t0280-plugin-git.sh 1.03 KB
Newer Older
Łukasz Magiera's avatar
Łukasz Magiera committed
1
#!/usr/bin/env bash
2
#
Jakub Sztandera's avatar
Jakub Sztandera committed
3
# Copyright (c) 2017 Jakub Sztandera
4 5 6 7 8 9 10 11 12
# MIT Licensed; see the LICENSE file in this repository.
#

test_description="Test git plugin"

. lib/test-lib.sh

test_init_ipfs

Łukasz Magiera's avatar
Łukasz Magiera committed
13 14
# from https://github.com/ipfs/go-ipld-git/blob/master/make-test-repo.sh
test_expect_success "prepare test data" '
Łukasz Magiera's avatar
Łukasz Magiera committed
15
  tar xzf ../t0280-plugin-git-data/git.tar.gz
Łukasz Magiera's avatar
Łukasz Magiera committed
16 17 18
'

test_dag_git() {
Łukasz Magiera's avatar
Łukasz Magiera committed
19 20 21 22 23 24 25 26 27 28
  test_expect_success "add objects via dag put" '
    find objects -type f -exec ipfs dag put --format=git --input-enc=zlib {} \; -exec echo \; > hashes
  '

  test_expect_success "successfully get added objects" '
    cat hashes | xargs -i ipfs dag get -- {} > /dev/null
  '

  test_expect_success "path traversals work" '
    echo \"YmxvYiA3ACcsLnB5Zgo=\" > file1 &&
29
    ipfs dag get baf4bcfhzi72pcj5cc4ocz7igcduubuu7aa3cddi/object/parents/0/tree/dir2/hash/f3/hash > out1
Łukasz Magiera's avatar
Łukasz Magiera committed
30 31 32 33 34
  '

  test_expect_success "outputs look correct" '
    test_cmp file1 out1
  '
Łukasz Magiera's avatar
Łukasz Magiera committed
35 36 37 38 39 40 41 42 43
}

# should work offline
#test_dag_git

# should work online
test_launch_ipfs_daemon
test_dag_git
test_kill_ipfs_daemon
44 45

test_done