From 6d42c5ec7a44590c7b46cce84cb3c877fe81823f Mon Sep 17 00:00:00 2001 From: Dominic Ricottone Date: Fri, 16 Sep 2022 21:52:09 -0500 Subject: [PATCH] rmold update Added test suite. Corrected the name that rmold would self-report as. --- core/rmold | 4 ++-- core/test/rmold.bats | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 core/test/rmold.bats diff --git a/core/rmold b/core/rmold index 2f427fc..b6fe0c6 100755 --- a/core/rmold +++ b/core/rmold @@ -1,10 +1,10 @@ #!/bin/sh -name="rm-old" +name="rmold" version="1.0" help_message=$(/usr/bin/cat <<-EOF Delete files older than a year - Usage: rm-old [PATH] + Usage: rmold [PATH] Options: -h, --help print this message and exit -v, --version print version number and exit diff --git a/core/test/rmold.bats b/core/test/rmold.bats new file mode 100644 index 0000000..e27b0cd --- /dev/null +++ b/core/test/rmold.bats @@ -0,0 +1,39 @@ +#!/usr/bin/env bats +bats_require_minimum_version 1.5.0 + +@test "rmold version" { + run --separate-stderr rmold --version + [ "$status" -eq 0 ] + [ "$output" = "rmold 1.0" ] + [ "$stderr" = "" ] +} + +@test "rmold version short" { + run --separate-stderr rmold -v + [ "$status" -eq 0 ] + [ "$output" = "rmold 1.0" ] + [ "$stderr" = "" ] +} + +@test "rmold help" { + run --separate-stderr rmold --help + [ "$status" -eq 0 ] + [ "${lines[0]}" = "Delete files older than a year" ] + [ "${lines[1]}" = "Usage: rmold [PATH]" ] + [ "${lines[2]}" = "Options:" ] + [ "${lines[3]}" = " -h, --help print this message and exit" ] + [ "${lines[4]}" = " -v, --version print version number and exit" ] + [ "$stderr" = "" ] +} + +@test "rmold help short" { + run --separate-stderr rmold -h + [ "$status" -eq 0 ] + [ "${lines[0]}" = "Delete files older than a year" ] + [ "${lines[1]}" = "Usage: rmold [PATH]" ] + [ "${lines[2]}" = "Options:" ] + [ "${lines[3]}" = " -h, --help print this message and exit" ] + [ "${lines[4]}" = " -v, --version print version number and exit" ] + [ "$stderr" = "" ] +} + -- 2.45.2