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 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
|
#!/usr/bin/env bats
load helper
setup() {
$HDFS mkdir -p /_test_cmd/mv/dir1
$HDFS mkdir -p /_test_cmd/mv/dir2
$HDFS touch /_test_cmd/mv/a
$HDFS touch /_test_cmd/mv/b
$HDFS touch /_test_cmd/mv/dir1/c
}
@test "mv" {
run $HDFS mv /_test_cmd/mv/a /_test_cmd/mv/moved
assert_success
assert_output ""
run $HDFS ls /_test_cmd/mv/a
assert_failure
run $HDFS ls /_test_cmd/mv/moved
assert_success
}
@test "mv nonexistent" {
run $HDFS mv /_test_cmd/nonexistent /_test_cmd/nonexistent2
assert_failure
assert_output <<OUT
rename /_test_cmd/nonexistent: file does not exist
OUT
}
@test "mv into dir" {
run $HDFS mv /_test_cmd/mv/a /_test_cmd/mv/dir1
assert_success
assert_output ""
run $HDFS ls /_test_cmd/mv/a
assert_failure
run $HDFS ls /_test_cmd/mv/dir1/a
assert_success
}
@test "mv into existing" {
run $HDFS mv /_test_cmd/mv/a /_test_cmd/mv/b
assert_success
assert_output ""
run $HDFS ls /_test_cmd/mv/a
assert_failure
run $HDFS ls /_test_cmd/mv/b
assert_success
}
@test "mv into existing with -n" {
run $HDFS mv -n /_test_cmd/mv/a /_test_cmd/mv/b
assert_failure
assert_output <<OUT
rename /_test_cmd/mv/b: file already exists
OUT
}
@test "mv into dir with -n" {
run $HDFS mv -n /_test_cmd/mv/a /_test_cmd/mv/dir1
assert_success
assert_output ""
run $HDFS ls /_test_cmd/mv/a
assert_failure
run $HDFS ls /_test_cmd/mv/dir1/a
assert_success
}
@test "mv with -T" {
run $HDFS mv -T /_test_cmd/mv/a /_test_cmd/mv/moved
assert_success
assert_output ""
run $HDFS ls /_test_cmd/mv/a
assert_failure
run $HDFS ls /_test_cmd/mv/moved
assert_success
}
@test "mv into existing dir with -T" {
run $HDFS mv -T /_test_cmd/mv/a /_test_cmd/mv/dir1
assert_failure
assert_output <<OUT
Can't replace directory with non-directory.
OUT
}
@test "mv into existing dir with -nT" {
run $HDFS mv -nT /_test_cmd/mv/a /_test_cmd/mv/dir1
assert_failure
assert_output <<OUT
Can't replace directory with non-directory.
OUT
}
@test "mv dir into existing dir" {
run $HDFS mv /_test_cmd/mv/dir1 /_test_cmd/mv/dir2
assert_success
assert_output ""
run $HDFS ls /_test_cmd/mv/dir1
assert_failure
run $HDFS ls /_test_cmd/mv/dir2
assert_success
}
@test "mv dir into existing dir with -T" {
run $HDFS mv -T /_test_cmd/mv/dir1 /_test_cmd/mv/dir2
assert_success
assert_output ""
run $HDFS ls /_test_cmd/mv/dir1
assert_failure
run $HDFS ls /_test_cmd/mv/dir2
assert_success
}
@test "mv dir into existing dir with -nT" {
run $HDFS mv -nT /_test_cmd/mv/dir1 /_test_cmd/mv/dir2
assert_failure
assert_output <<OUT
rename /_test_cmd/mv/dir2: file already exists
OUT
}
teardown() {
$HDFS rm -r /_test_cmd/mv
}
|