#!/usr/bin/env bash
# tests against lib/aliases.sh


MSU_EXTERNAL_LIB="${BATS_TMPDIR:-/tmp}/test-aliases"


function setup() {
  # shellcheck disable=SC2015
  mkdir -p "${MSU_EXTERNAL_LIB}"
}


function teardown() {
  rm -rf "${MSU_EXTERNAL_LIB:-/tmp}/*"
}


@test "aliases.sh loads aliases into the current environment" {
  . lib/aliases.sh
  alias x
  alias msu.reload
}


@test "aliases.sh loads aliases from external modules" {
  local mod="${MSU_EXTERNAL_LIB}/aliases"
  mkdir -p "${mod}"
  echo "alias humansshouldriseup='echo external'" > "${mod}/aliases.sh"
  . lib/aliases.sh
  alias humansshouldriseup | grep "external"
}


@test "\${MSU_EXTERNAL_LIB}/aliases.sh overides all" {
  local alias_override="${MSU_EXTERNAL_LIB}/aliases.sh"
  local mod="${MSU_EXTERNAL_LIB}/overide"
  mkdir -p "${mod}"
  echo "alias bedaring='echo override'" > "${alias_override}"
  echo "alias bedaring='echo external'" > "${mod}/aliases.sh"
  . lib/aliases.sh
  alias bedaring | grep "override"
}

#!/usr/bin/env bash
# tests against lib/aliases.sh


MSU_EXTERNAL_LIB="${BATS_TMPDIR:-/tmp}/test-aliases"


function setup() {
  # shellcheck disable=SC2015
  mkdir -p "${MSU_EXTERNAL_LIB}"
}


function teardown() {
  rm -rf "${MSU_EXTERNAL_LIB:-/tmp}/*"
}


@test "aliases.sh loads aliases into the current environment" {
  . lib/aliases.sh
  alias msu.fs.join
  alias msu.net.dl
}


@test "aliases.sh loads aliases from external modules" {
  local mod="${MSU_EXTERNAL_LIB}/aliases"
  mkdir -p "${mod}"
  echo "alias humansshouldriseup='echo external'" > "${mod}/aliases.sh"
  . lib/aliases.sh
  alias humansshouldriseup | grep "external"
}


@test "\${MSU_EXTERNAL_LIB}/aliases.sh overides all" {
  local alias_override="${MSU_EXTERNAL_LIB}/aliases.sh"
  local mod="${MSU_EXTERNAL_LIB}/overide"
  mkdir -p "${mod}"
  echo "alias bedaring='echo override'" > "${alias_override}"
  echo "alias bedaring='echo external'" > "${mod}/aliases.sh"
  . lib/aliases.sh
  alias bedaring | grep "override"
}

--- 
+++ 
@@ -18,8 +18,8 @@
 
 @test "aliases.sh loads aliases into the current environment" {
   . lib/aliases.sh
-  alias x
-  alias msu.reload
+  alias msu.fs.join
+  alias msu.net.dl
 }
 
 
Fix errors reported by travis
