File: install-linux_test_helpers.sh

package info (click to toggle)
opkssh 0.10.0-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,440 kB
  • sloc: sh: 2,062; makefile: 11
file content (53 lines) | stat: -rw-r--r-- 1,343 bytes parent folder | download | duplicates (3)
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
#!/bin/bash
export SHUNIT_RUNNING=1


# Source install-linux.sh
# shellcheck disable=SC1091
source "$(dirname "${BASH_SOURCE[0]}")/../install-linux.sh"

setUp() {
    TEST_DIR=$(mktemp -d)
    TEST_FILE="$TEST_DIR/sample.txt"
    mkdir "$TEST_DIR/subdir"
    touch "$TEST_FILE"
}

tearDown() {
    rm -rf "$TEST_DIR"
}

# Test file_exists
test_file_exists_returns_true_for_file() {
    file_exists "$TEST_FILE"
    assertTrue "Expected file_exists to return true for existing file" $?
}

test_file_exists_returns_false_for_missing_file() {
    file_exists "$TEST_DIR/nope.txt"
    assertFalse "Expected file_exists to return false for non-existent file" $?
}

test_file_exists_returns_false_for_directory() {
    file_exists "$TEST_DIR/subdir"
    assertFalse "Expected file_exists to return false for a directory" $?
}

# Test dir_exists
test_dir_exists_returns_true_for_directory() {
    dir_exists "$TEST_DIR/subdir"
    assertTrue "Expected dir_exists to return true for directory" $?
}

test_dir_exists_returns_false_for_file() {
    dir_exists "$TEST_FILE"
    assertFalse "Expected dir_exists to return false for a file" $?
}

test_dir_exists_returns_false_for_missing_path() {
    dir_exists "$TEST_DIR/ghost"
    assertFalse "Expected dir_exists to return false for non-existent path" $?
}

# shellcheck disable=SC1091
source shunit2