#!/usr/bin/env bash

##
# NOTE: This test is designed to run in bazel!
##

set -euox pipefail

TEST_COMMAND="vehicle/puffin/src/resources/scripts/get_main_ai_disk.sh"

function test_successful_script() {
  remote_command(){
  # This test data was grabbed from a kitt troubleshooting thread.
  echo "Filesystem                  1K-blocks      Used  Available Use% Mounted on
udev                         65924752         4   65924748   1% /dev
tmpfs                        13189960      2152   13187808   1% /run
/dev/sdc3                    32896880  13713648   17489128  44% /overlay/os
/dev/sdc5                   245945504 127335592  106093512  55% /overlay/deploy
/dev/sdc2                      999320      1552     928956   1% /overlay/customization
overlay                     245945504 127335592  106093512  55% /
none                                4         0          4   0% /sys/fs/cgroup
none                             5120         0       5120   0% /run/lock
none                         65949784    404532   65545252   1% /run/shm
none                           102400        28     102372   1% /run/user
/dev/sdc1                     1046516       876    1045640   1% /boot/efi
/dev/mapper/lvm-imageries  1031992064 471654060  507892820  49% /home/zoox/imageries
/dev/mapper/lvm-zoox_cache  206293688  17813404  177978140  10% /home/zoox/.cache/build-deployer
/dev/md0                   7752132916     51360 7361373692   1% /media/zoox/zooxdata
"
  }
  output="$(HOME="." source ${TEST_COMMAND})"
  if [[ ${output} = "/dev/md0                   7752132916     51360 7361373692   1% /media/zoox/zooxdata" ]]; then
      echo " Script correctly exited normal execution."
  else
      echo " Script failed execution."
      exit 1
  fi
}

test_successful_script
