Skip to content

Commit

Permalink
fix: get current dir error
Browse files Browse the repository at this point in the history
  • Loading branch information
jwrookie committed Jan 7, 2022
2 parents fd82e5e + 7624f2a commit 4f7002c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ build
/compose/**/nginx.pid
/compose/etcd_data
manager-api
grpc-server-example/
api/test/docker/*tar.gz*

output
apisix_logs
Expand Down
11 changes: 8 additions & 3 deletions api/internal/handler/data_loader/route_import_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ import (
"mime/multipart"
"net/http"
"os"
"path"
"path/filepath"
"runtime"
"strings"
"testing"

Expand Down Expand Up @@ -93,8 +94,12 @@ func ReadFile(t *testing.T, filePath string) []byte {
pwd, err := os.Getwd()
assert.Nil(t, err)

apiDir := path.Join(strings.Split(pwd,"/api/")[0], "/api/")
fileContent, err := ioutil.ReadFile(path.Join(apiDir, filePath))
bound := "/api/"
if runtime.GOOS == "windows" {
bound = `\api\`
}
apiDir := filepath.Join(strings.Split(pwd,bound)[0], bound)
fileContent, err := ioutil.ReadFile(filepath.Join(apiDir, filePath))
assert.Nil(t, err)

return fileContent
Expand Down
11 changes: 10 additions & 1 deletion api/test/docker/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,21 @@ up() {

fi

if [ ! -d "grpc-server-example" ]; then
wget https://github.com/api7/grpc_server_example/archive/refs/tags/20210819.tar.gz
mkdir grpc-server-example
tar -xzvf 20210819.tar.gz -C grpc-server-example
docker build -t grpc_server_example:latest ./grpc-server-example/grpc_server_example-20210819
fi

#Spinning up services
if [ -z "$1" ]; then
docker-compose up
else
docker-compose up "$1"
fi

../shell/wait_for_services.sh
}

down() {
Expand Down Expand Up @@ -141,7 +150,7 @@ welcome() {
echo "Services: "
echo "1. Three etcd nodes."
echo "2. Two apisix nodes."
echo -e "3. Single node of\n\t manager-api \n\t skywalking \n\t upstream-node"
echo -e "3. Single node of\n\t manager-api \n\t skywalking \n\t upstream-node \n\t upstream-grpc \n\t upstream-echo"
echo -e "=====================================================\n"
}

Expand Down

0 comments on commit 4f7002c

Please sign in to comment.