/ scripts / unit_test_modules.sh
unit_test_modules.sh
 1  #!/bin/bash
 2  
 3  IGNORE="tools"
 4  SUBMODULES=$(find . -mindepth 2 -name "go.mod" | cut -d'/' -f2 | grep -v "$IGNORE")
 5  
 6  for submodule in $SUBMODULES
 7  do
 8    pushd $submodule
 9  
10    echo "Running submodule unit tests in $(pwd)"
11    echo "testing $submodule..."
12    go test -timeout=5m || exit 1
13    
14    if [[ "$submodule" == "kvdb" ]]
15    then
16        echo "testing $submodule with sqlite..."
17        go test -tags="kvdb_sqlite" -timeout=5m || exit 1
18        
19        echo "testing $submodule with postgres..."
20        go test -tags="kvdb_postgres" -timeout=5m || exit 1
21        
22        echo "testing $submodule with etcd..."
23        go test -tags="kvdb_etcd" -timeout=5m || exit 1
24    fi
25    
26    popd
27  done