~dricottone/my-utils

ref: 573855ab6e5eeaee1e0c935bb6fcf78bf02e13f1 my-utils/archives/test/untar.bats -rw-r--r-- 2.2 KiB
573855abDominic Ricottone Rewrote test suite for bats 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env bats
bats_require_minimum_version 1.5.0

setup() {
  mkdir -p test/static test/output
  printf "(a)\n(b)\n(c)\n\n" > test/static/decompression_result.txt
  cd test/static
  tar -cf decompression_target.tar decompression_result.txt
  tar -czf decompression_target.tar.gz decompression_result.txt
  tar -cJf decompression_target.tar.xz decompression_result.txt
  tar --zstd -cf decompression_target.tar.zst decompression_result.txt
  cp decompression_target.tar.zst decompression_target.tar.zstd
  tar -cjf decompression_target.tar.bz2 decompression_result.txt
  mv decompression_result.txt decompression_target.txt
  cd ../..
}

teardown() {
  rm -rf test/static test/output
}

@test "untar none" {
  run --separate-stderr untar --to-directory test/output/ test/static/decompression_target.tar
  [ "$status" -eq 0 ]
  [ "$output" = "" ]
  [ "$stderr" = "" ]
  cmp test/output/decompression_result.txt test/static/decompression_target.txt
}

@test "untar gzip" {
  run --separate-stderr untar --to-directory test/output/ test/static/decompression_target.tar.gz
  [ "$status" -eq 0 ]
  [ "$output" = "" ]
  [ "$stderr" = "" ]
  cmp test/output/decompression_result.txt test/static/decompression_target.txt
}

@test "untar xz" {
  run --separate-stderr untar --to-directory test/output/ test/static/decompression_target.tar.xz
  [ "$status" -eq 0 ]
  [ "$output" = "" ]
  [ "$stderr" = "" ]
  cmp test/output/decompression_result.txt test/static/decompression_target.txt
}

@test "untar zstd" {
  run --separate-stderr untar --to-directory test/output/ test/static/decompression_target.tar.zst
  [ "$status" -eq 0 ]
  [ "$output" = "" ]
  [ "$stderr" = "" ]
  cmp test/output/decompression_result.txt test/static/decompression_target.txt
}

@test "untar zstd alt" {
  run --separate-stderr untar --to-directory test/output/ test/static/decompression_target.tar.zstd
  [ "$status" -eq 0 ]
  [ "$output" = "" ]
  [ "$stderr" = "" ]
  cmp test/output/decompression_result.txt test/static/decompression_target.txt
}

@test "untar bzip2" {
  run --separate-stderr untar --to-directory test/output/ test/static/decompression_target.tar.bz2
  [ "$status" -eq 0 ]
  [ "$output" = "" ]
  [ "$stderr" = "" ]
  cmp test/output/decompression_result.txt test/static/decompression_target.txt
}