1
exercism fetch bash error-handling

error_handling_test.sh

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
#!/usr/bin/env bats

@test "correct arguments" {
    #skip
    run bash error_handling.sh Alice
    
    [ "$status" -eq 0 ]
    [ "$output" = "Hello, Alice" ]
}

@test "one long argument" {
    skip
    run bash error_handling.sh "Alice and Bob"
    
    [ "$status" -eq 0 ]
    [ "$output" = "Hello, Alice and Bob" ]
}

@test "incorrect arguments" {
    skip
    run bash error_handling.sh Alice Bob

    [ "$status" -ne 0 ]
}

@test "use errexit" {
    skip
    source error_handling.sh
    [ echo $SHELLOPTS | grep -q 'errexit' ]
}

@test "use nounset" {
    skip
    source error_handling.sh
    [ echo $SHELLOPTS | grep -q 'nounset' ]
}