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
|
#!/usr/bin/env bats
load helper
setup() {
$HDFS mkdir -p /_test_cmd/glob/dir1/dir/
$HDFS mkdir -p /_test_cmd/glob/dir2/dir/
$HDFS mkdir -p /_test_cmd/glob/dir3/
$HDFS touch /_test_cmd/glob/dir1/foo
$HDFS touch /_test_cmd/glob/dir1/dir/a
$HDFS touch /_test_cmd/glob/dir1/dir/b
$HDFS touch /_test_cmd/glob/dir1/dir/c
$HDFS touch /_test_cmd/glob/dir2/dir/d
}
@test "ls with glob" {
run $HDFS ls /_test_cmd/glob/dir*/dir
assert_success
assert_output <<OUT
/_test_cmd/glob/dir1/dir/:
a
b
c
/_test_cmd/glob/dir2/dir/:
d
OUT
}
@test "ls with two globs" {
run $HDFS ls /_test_cmd/glob/*/*
assert_success
assert_output <<OUT
/_test_cmd/glob/dir1/foo
/_test_cmd/glob/dir1/dir/:
a
b
c
/_test_cmd/glob/dir2/dir/:
d
OUT
}
@test "ls with two globs, one of which is qualified" {
run $HDFS ls /_test_cmd/glob/dir*/*
assert_success
assert_output <<OUT
/_test_cmd/glob/dir1/foo
/_test_cmd/glob/dir1/dir/:
a
b
c
/_test_cmd/glob/dir2/dir/:
d
OUT
}
@test "ls with two globs, two of which are qualified" {
run $HDFS ls /_test_cmd/glob/dir*/dir*
assert_success
assert_output <<OUT
/_test_cmd/glob/dir1/dir/:
a
b
c
/_test_cmd/glob/dir2/dir/:
d
OUT
}
@test "ls with three globs" {
run $HDFS ls /_test_cmd/glob/*/*/*
assert_success
assert_output <<OUT
/_test_cmd/glob/dir1/dir/a
/_test_cmd/glob/dir1/dir/b
/_test_cmd/glob/dir1/dir/c
/_test_cmd/glob/dir2/dir/d
OUT
}
# qualify the files portion unless there's one path and it's a directory
@test "ls with three globs, one of which is qualified" {
run $HDFS ls /_test_cmd/glob/dir*/*/*
assert_success
assert_output <<OUT
/_test_cmd/glob/dir1/dir/a
/_test_cmd/glob/dir1/dir/b
/_test_cmd/glob/dir1/dir/c
/_test_cmd/glob/dir2/dir/d
OUT
}
@test "ls nonexistent blob" {
run $HDFS ls /_test_cmd/nonexistent*
assert_failure
assert_output <<OUT
stat /_test_cmd/nonexistent*: file does not exist
OUT
}
# teardown() {
# $HDFS rm -r /_test_cmd/glob
# }
|