~dricottone/my-utils

my-utils/archives/test/tarcat.bats -rw-r--r-- 2.1 KiB
a5400e39Dominic Ricottone Starting point for cryptographic utilities 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
#!/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
  tar -cf test/static/decompression_target.tar test/static/decompression_result.txt
  tar -czf test/static/decompression_target.tar.gz test/static/decompression_result.txt
  tar -cJf test/static/decompression_target.tar.xz test/static/decompression_result.txt
  tar --zstd -cf test/static/decompression_target.tar.zst test/static/decompression_result.txt
  cp test/static/decompression_target.tar.zst test/static/decompression_target.tar.zstd
  tar -cjf test/static/decompression_target.tar.bz2 test/static/decompression_result.txt
  mv test/static/decompression_result.txt test/static/decompression_target.txt
}

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

@test "tarcat none" {
  run --separate-stderr sh -c 'tarcat test/static/decompression_target.tar | cmp test/static/decompression_target.txt >/dev/null 2>&1'
  [ "$status" -eq 0 ]
  [ "$output" = "" ]
  [ "$stderr" = "" ]
}

@test "tarcat gzip" {
  run --separate-stderr sh -c 'tarcat test/static/decompression_target.tar.gz | cmp test/static/decompression_target.txt >/dev/null 2>&1'
  [ "$status" -eq 0 ]
  [ "$output" = "" ]
  [ "$stderr" = "" ]
}

@test "tarcat xz" {
  run --separate-stderr sh -c 'tarcat test/static/decompression_target.tar.xz | cmp test/static/decompression_target.txt >/dev/null 2>&1'
  [ "$status" -eq 0 ]
  [ "$output" = "" ]
  [ "$stderr" = "" ]
}

@test "tarcat zstd" {
  run --separate-stderr sh -c 'tarcat test/static/decompression_target.tar.zst | cmp test/static/decompression_target.txt >/dev/null 2>&1'
  [ "$status" -eq 0 ]
  [ "$output" = "" ]
  [ "$stderr" = "" ]
}

@test "tarcat zstd alt" {
  run --separate-stderr sh -c 'tarcat test/static/decompression_target.tar.zstd | cmp test/static/decompression_target.txt >/dev/null 2>&1'
  [ "$status" -eq 0 ]
  [ "$output" = "" ]
  [ "$stderr" = "" ]
}

@test "tarcat bzip2" {
  run --separate-stderr sh -c 'tarcat test/static/decompression_target.tar.bz2 | cmp test/static/decompression_target.txt >/dev/null 2>&1'
  [ "$status" -eq 0 ]
  [ "$output" = "" ]
  [ "$stderr" = "" ]
}