Commit 8e122b9a authored by Giannis Kepas's avatar Giannis Kepas
Browse files

fix assignment 2 tests

parent 66065d7c
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -5,22 +5,22 @@ setup() {
    load '../../bats/bats-assert/load'
}

@test "[TASK 2] test 1: should print 'is a file' for argument 'task-2.sh'" {
@test "[TASK 2] test 1: should print 'is a file' for parameter 'task-2.sh'" {
    run ./task-2.sh "task-2.sh"
    assert_output --partial 'file'
}

@test "[TASK 2] test 2: should print 'is a directory' for argument 'os-tests'" {
@test "[TASK 2] test 2: should print 'is a directory' for parameter 'os-tests'" {
    run ./task-2.sh "os-tests"
    assert_output --partial 'directory'
}

@test "[TASK 2] test 3: should print 'There is no such file or directory' for argument 'abcdefg.hello'" {
@test "[TASK 2] test 3: should print 'There is no such file or directory' for parameter 'abcdefg.hello'" {
    run ./task-2.sh "abcdefg.hello"
    assert_output --partial 'no such file or directory'
}

@test "[TASK 2] test 4: should print 'Invalid number of parameters' for arguments 'task-2.sh' and 'task-2.sh'" {
@test "[TASK 2] test 4: should print 'Invalid number of parameters' for parameters 'task-2.sh' and 'task-2.sh'" {
    run ./task-2.sh "task-2.sh" "task-2.sh"
    assert_output --partial 'Invalid number of parameters'
}
+15 −12
Original line number Diff line number Diff line
#!/usr/bin/env bats

# Dynamic current year calculation.
CURRENT_YEAR=$(date +%Y)

setup() {
    load '../../bats/bats-support/load'
    load '../../bats/bats-assert/load'
}

@test "[TASK 3] test 1: should print 'Hello little baby' for input '10'" {
    run ./task-3.sh <<< "10"
@test "[TASK 3] test 1: should print 'Hello little baby' for input '10/01/$(($CURRENT_YEAR - 10))'" {
    run ./task-3.sh <<< "10/01/$(($CURRENT_YEAR - 10))"
    assert_output --partial 'Hello little baby'
}

@test "[TASK 3] test 2: should print 'Hello teenager' for input '15'" {
    run ./task-3.sh <<< "15"
@test "[TASK 3] test 2: should print 'Hello teenager' for input '10/01/$(($CURRENT_YEAR - 15))'" {
    run ./task-3.sh <<< "10/01/$(($CURRENT_YEAR - 15))"
    assert_output --partial 'Hello teenager'
}

@test "[TASK 3] test 3: should print 'Hello little mister' for input '30'" {
    run ./task-3.sh <<< "30"
@test "[TASK 3] test 3: should print 'Hello little mister' for input '10/01/$(($CURRENT_YEAR - 30))'" {
    run ./task-3.sh <<< "10/01/$(($CURRENT_YEAR - 30))"
    assert_output --partial 'Hello little mister'
}

@test "[TASK 3] test 4: should print 'Hello little mister' for input '45'" {
    run ./task-3.sh <<< "45"
    assert_output --partial 'Hello little mister'
@test "[TASK 3] test 4: should print 'Hello mister' for input '10/01/$(($CURRENT_YEAR - 50))'" {
    run ./task-3.sh <<< "10/01/$(($CURRENT_YEAR - 50))"
    assert_output --partial 'Hello mister'
}

@test "[TASK 3] test 5: should print 'Hello mister' for input '50'" {
    run ./task-3.sh <<< "50"
    assert_output --partial 'Hello mister'
@test "[TASK 3] test 5: should print 'Something went wrong...' for input '10/01/$(($CURRENT_YEAR + 100))'" {
    run ./task-3.sh <<< "10/01/$(($CURRENT_YEAR + 100))"
    assert_output --partial 'Something went wrong...'
}
+4 −4
Original line number Diff line number Diff line
@@ -7,12 +7,12 @@ setup() {

@test "[TASK 4] test 1: should print 'One' for input '1'" {
    run ./task-4.sh <<< "1"
    assert_output --partial 'Two'
    assert_output --partial 'One'
}

@test "[TASK 4] test 2: should print 'Two' for input '2'" {
    run ./task-4.sh <<< "2"
    assert_output --partial 'One'
    assert_output --partial 'Two'
}

@test "[TASK 4] test 3: should print 'Three' for input '3'" {
@@ -50,7 +50,7 @@ setup() {
    assert_output --partial 'Nine'
}

@test "[TASK 4] test 10: should print 'Ten' for input '10'" {
@test "[TASK 4] test 10: should print 'Not a single-digit number' for input '10'" {
    run ./task-4.sh <<< "10"
    assert_output --partial 'Ten'
    assert_output --partial 'Not a single-digit number'
}
+7 −7
Original line number Diff line number Diff line
@@ -6,26 +6,26 @@ setup() {
}

@test "[TASK 5] test 1: should print 'User root found' for input 'root'" {
    run ./task-5.sh <<< "root"
    assert_output --partial 'User root found'
    run ./task-5.sh "root"
    assert_output --partial "User 'root' found"
}

@test "[TASK 5] test 2: should print 'User not found' for input '921c7n2eynnhe8'" {
    run ./task-5.sh <<< "921c7n2eynnhe8"
    run ./task-5.sh "921c7n2eynnhe8"
    assert_output --partial 'User not found'
}

@test "[TASK 5] test 3: should print 'User not found' for input 'root1'" {
    run ./task-5.sh <<< "root1"
    run ./task-5.sh "root1"
    assert_output --partial 'User not found'
}

@test "[TASK 5] test 4: should print 'User nobody found' for input 'nobody'" {
    run ./task-5.sh <<< "nobody"
    assert_output --partial 'User nobody found'
    run ./task-5.sh "nobody"
    assert_output --partial "User 'nobody' found"
}

@test "[TASK 5] test 5: should print 'User not found' for input 'function'" {
    run ./task-5.sh <<< "function"
    run ./task-5.sh "function"
    assert_output --partial 'User not found'
}