github.com/dolanor/pop@v4.13.0+incompatible/test.sh (about)

     1  #!/bin/bash
     2  
     3  ########################################################
     4  # test.sh is a wrapper to execute integration tests for
     5  # pop.
     6  ########################################################
     7  
     8  set -e
     9  clear
    10  
    11  VERBOSE=""
    12  DEBUG='NO'
    13  
    14  for i in "$@"
    15  do
    16  case $i in
    17      -v)
    18      VERBOSE="-v"
    19      shift
    20      ;;
    21      -d)
    22      DEBUG='YES'
    23      shift
    24      ;;
    25      *)
    26        # unknown option
    27      ;;
    28  esac
    29  done
    30  
    31  function cleanup {
    32    echo "Cleanup resources..."
    33    docker-compose down
    34    rm tsoda
    35    find ./sql_scripts/sqlite -name *.sqlite* -delete
    36  }
    37  # defer cleanup, so it will be executed even after premature exit
    38  trap cleanup EXIT
    39  
    40  docker-compose up -d
    41  sleep 4 # Ensure mysql is online
    42  
    43  go build -v -tags sqlite -o tsoda ./soda
    44  
    45  export GO111MODULE=on
    46  
    47  function test {
    48    echo "!!! Testing $1"
    49    export SODA_DIALECT=$1
    50    echo ./tsoda -v
    51    echo "Setup..."
    52    ./tsoda drop -e $SODA_DIALECT -c ./database.yml -p ./testdata/migrations
    53    ./tsoda create -e $SODA_DIALECT -c ./database.yml -p ./testdata/migrations
    54    ./tsoda migrate -e $SODA_DIALECT -c ./database.yml -p ./testdata/migrations
    55    echo "Test..."
    56    go test -race -tags sqlite $VERBOSE ./... -count=1
    57  }
    58  
    59  function debug_test {
    60      echo "!!! Debug Testing $1"
    61      export SODA_DIALECT=$1
    62      echo ./tsoda -v
    63      echo "Setup..."
    64      ./tsoda drop -e $SODA_DIALECT -c ./database.yml -p ./testdata/migrations
    65      ./tsoda create -e $SODA_DIALECT -c ./database.yml -p ./testdata/migrations
    66      ./tsoda migrate -e $SODA_DIALECT -c ./database.yml -p ./testdata/migrations
    67      echo "Test and debug..."
    68      dlv test github.com/gobuffalo/pop
    69  }
    70  
    71  dialects=("postgres" "cockroach" "mysql" "sqlite")
    72  
    73  for dialect in "${dialects[@]}" ; do
    74    if [ $DEBUG = 'NO' ]; then
    75    test ${dialect}
    76    else
    77    debug_test ${dialect}
    78    fi
    79  done