File: rm.bats

package info (click to toggle)
golang-github-colinmarc-hdfs 2.3.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 3,760 kB
  • sloc: sh: 130; xml: 40; makefile: 31
file content (59 lines) | stat: -rw-r--r-- 1,173 bytes parent folder | download
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
#!/usr/bin/env bats

load helper

setup() {
  $HDFS mkdir -p /_test_cmd/rm/dir
  $HDFS touch /_test_cmd/rm/a
  $HDFS touch /_test_cmd/rm/b
  $HDFS touch /_test_cmd/rm/dir/c
}

@test "rm" {
  run $HDFS rm /_test_cmd/rm/a
  assert_success
  assert_output ""

  run $HDFS ls /_test_cmd/rm/a
  assert_failure
}

@test "rm dir" {
  run $HDFS rm -r /_test_cmd/rm/dir
  assert_success
  assert_output ""

  run $HDFS ls /_test_cmd/rm/dir
  assert_failure
}

@test "rm dir without -r" {
  run $HDFS rm /_test_cmd/rm/dir
  assert_failure
  assert_output "remove /_test_cmd/rm/dir: file is a directory"
}

@test "rm dir without -r, but with -f" {
  run $HDFS rm -f /_test_cmd/rm/dir
  assert_failure
  assert_output "remove /_test_cmd/rm/dir: file is a directory"
}

@test "rm nonexistent" {
  run $HDFS rm /_test_cmd/nonexistent /_test_cmd/nonexistent2
  assert_failure
  assert_output <<OUT
remove /_test_cmd/nonexistent: file does not exist
remove /_test_cmd/nonexistent2: file does not exist
OUT
}

@test "rm nonexistent with -f" {
  run $HDFS rm -f /_test_cmd/nonexistent /_test_cmd/nonexistent2
  assert_success
  assert_output ""
}

teardown() {
  $HDFS rm -r /_test_cmd/rm
}