~dricottone/my-utils

6d42c5ec7a44590c7b46cce84cb3c877fe81823f — Dominic Ricottone 2 years ago 75f4722
rmold update

Added test suite.

Corrected the name that rmold would self-report as.
2 files changed, 41 insertions(+), 2 deletions(-)

M core/rmold
A core/test/rmold.bats
M core/rmold => core/rmold +2 -2
@@ 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

A core/test/rmold.bats => core/test/rmold.bats +39 -0
@@ 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" = "" ]
}