init: 初始化 AssetX 项目仓库
包含 webapp(Next.js 用户端)、webapp-back(Go 后端)、 antdesign(管理后台)、landingpage(营销落地页)、 数据库 SQL 和配置文件。
This commit is contained in:
19
webapp-back/scripts/coverage.sh
Normal file
19
webapp-back/scripts/coverage.sh
Normal file
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
# http://stackoverflow.com/a/21142256/2055281
|
||||
|
||||
echo "mode: atomic" > coverage.out
|
||||
|
||||
for d in $(find ./* -maxdepth 10 -type d); do
|
||||
if ls $d/*.go &> /dev/null; then
|
||||
go test -coverprofile=profile.out -covermode=atomic $d
|
||||
if [ -f profile.out ]; then
|
||||
echo "$(pwd)"
|
||||
cat profile.out | grep -v "mode: " >> coverage.out
|
||||
rm profile.out
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
15
webapp-back/scripts/gofmt.sh
Normal file
15
webapp-back/scripts/gofmt.sh
Normal file
@@ -0,0 +1,15 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Check if all Go files are properly formatted
|
||||
unformatted=$(gofmt -l .)
|
||||
echo "$unformatted"
|
||||
|
||||
if [ -n "$unformatted" ]; then
|
||||
echo "There is unformatted code, you should use 'go fmt ./...' to format it."
|
||||
echo "Unformatted files:"
|
||||
echo "$unformatted"
|
||||
exit 1
|
||||
else
|
||||
echo "Codes are formatted."
|
||||
exit 0
|
||||
fi
|
||||
59
webapp-back/scripts/run-api-tests.sh
Normal file
59
webapp-back/scripts/run-api-tests.sh
Normal file
@@ -0,0 +1,59 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
# Ensure tmp directory exists
|
||||
mkdir -p ./tmp
|
||||
|
||||
# Clean up database
|
||||
rm -f ./data/gorm.db
|
||||
|
||||
# Download Postman collection
|
||||
echo "Downloading Postman collection..."
|
||||
curl -L -s https://raw.githubusercontent.com/gothinkster/realworld/main/api/Conduit.postman_collection.json -o ./tmp/Conduit.postman_collection.json
|
||||
|
||||
# Build the application
|
||||
echo "Building application..."
|
||||
go build -o app hello.go
|
||||
|
||||
# Start the server
|
||||
echo "Starting server..."
|
||||
PORT=8080 ./app &
|
||||
SERVER_PID=$!
|
||||
|
||||
# Cleanup function to kill server on exit
|
||||
cleanup() {
|
||||
echo "Stopping server..."
|
||||
kill $SERVER_PID
|
||||
rm -f app
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
# Wait for server to be ready
|
||||
echo "Waiting for server to be ready..."
|
||||
for i in {1..30}; do
|
||||
if curl -s http://localhost:8080/api/ping > /dev/null; then
|
||||
echo "Server is up!"
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
|
||||
# Run Newman
|
||||
echo "Running API tests..."
|
||||
# Check if newman is available
|
||||
if ! command -v newman &> /dev/null; then
|
||||
echo "newman not found, trying npx..."
|
||||
npx newman run ./tmp/Conduit.postman_collection.json \
|
||||
--global-var "APIURL=http://localhost:8080/api" \
|
||||
--global-var "EMAIL=test@example.com" \
|
||||
--global-var "PASSWORD=password" \
|
||||
--global-var "USERNAME=testuser" \
|
||||
--delay-request 50
|
||||
else
|
||||
newman run ./tmp/Conduit.postman_collection.json \
|
||||
--global-var "APIURL=http://localhost:8080/api" \
|
||||
--global-var "EMAIL=test@example.com" \
|
||||
--global-var "PASSWORD=password" \
|
||||
--global-var "USERNAME=testuser" \
|
||||
--delay-request 50
|
||||
fi
|
||||
Reference in New Issue
Block a user