This repository has been archived by the owner on Aug 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
201 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: User interface test | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set up golang | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: '1.20.x' | ||
|
||
- name: Set up environment | ||
uses: isbang/compose-action@v1.5.1 | ||
with: | ||
compose-file: "./docker-compose.ci.yml" | ||
|
||
- name: Install dependencies | ||
run: go mod tidy | ||
|
||
- name: Build target | ||
run: make user | ||
|
||
- name: Run local server | ||
run: cd ./output/user && nohup sh bootstrap.sh > nohup.out 2> nohup.err < /dev/null & | ||
|
||
- name: Test interfaces | ||
run: cd ../../test && go test -v |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
DIR = $(shell pwd) | ||
CMD = $(DIR)/CMD | ||
CONFIG_PATH = $(DIR)/config | ||
IDL_PATH = $(DIR)/idl | ||
OUTPUT_PATH = $(DIR)/output | ||
|
||
SERVICES := api user follow interaction video | ||
service = $(word 1, $@) | ||
|
||
# mock gen | ||
MOCKS := user_mock | ||
mock = $(word 1, $@) | ||
|
||
.PHONY: env-up | ||
env-up: | ||
docker-compose up -d | ||
|
||
.PHONY: env-down | ||
env-down: | ||
docker-compose down | ||
|
||
.PHONY: $(SERVICES) | ||
$(SERVICES): | ||
mkdir -p output | ||
cd $(CMD)/$(service) && sh build.sh | ||
cd $(CMD)/$(service)/output && cp -r . $(OUTPUT_PATH)/$(service) | ||
sh $(OUTPUT_PATH)/$(service)/bootstrap.sh | ||
|
||
|
||
.PHONY: $(MOCKS) | ||
$(MOCKS): | ||
@mkdir -p mocks | ||
mockgen -source=./idl/$(mock).go -destination=./mocks/$(mock).go -package=mocks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
version: '3.7' | ||
|
||
networks: | ||
tiktok: | ||
driver: bridge | ||
|
||
services: | ||
|
||
mysql: | ||
container_name: mysql | ||
image: mysql:latest | ||
restart: always | ||
environment: | ||
- MYSQL_ROOT_PASSWORD=root | ||
- MYSQL_DATABASE=tiktok | ||
- MYSQL_USER=tiktok | ||
- MYSQL_PASSWORD=tiktok | ||
- TZ=Asia/Shanghai | ||
volumes: | ||
- ./config/sql:/docker-entrypoint-initdb.d/ | ||
ports: | ||
- "3306:3306" | ||
networks: | ||
- tiktok | ||
|
||
redis: | ||
container_name: redis | ||
image: "redis:latest" | ||
restart: always | ||
ports: | ||
- 6379:6379 | ||
volumes: | ||
- /usr/local/redis/conf/redis.conf:/var/lib/redis/conf/redis.conf | ||
- /usr/local/redis/data:/data | ||
environment: | ||
- REDIS_PASSWORD=tiktok | ||
- ALLOW_EMPTY_PASSWORD=no | ||
networks: | ||
- tiktok | ||
|
||
rabbitmq: | ||
container_name: rabiitmq | ||
image: "rabbitmq:latest" | ||
ports: | ||
- 5672:5672 | ||
- 15672:15672 | ||
environment: | ||
- RABBITMQ_DEFAULT_USER=tiktok | ||
- RABBITMQ_DEFAULT_PASS=tiktok | ||
networks: | ||
- tiktok |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package main | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/ozline/tiktok/pkg/constants" | ||
|
||
"github.com/cloudwego/kitex/client" | ||
"github.com/ozline/tiktok/kitex_gen/user/userservice" | ||
) | ||
|
||
var ( | ||
conn userservice.Client | ||
username string | ||
password string | ||
token string | ||
id int64 | ||
) | ||
|
||
func TestMain(m *testing.M) { | ||
// 连接服务器 | ||
c, err := userservice.NewClient("user", | ||
client.WithMuxConnection(constants.MuxConnection), | ||
client.WithHostPorts("0.0.0.0:10002")) | ||
|
||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
username = "ozline" | ||
password = "123456" | ||
|
||
conn = c | ||
m.Run() | ||
} | ||
|
||
func TestMainOrder(t *testing.T) { | ||
t.Run("register", testRegister) | ||
|
||
t.Run("login", testLogin) | ||
|
||
t.Run("info", testGetUserInfo) | ||
|
||
t.Run("RPC Test", testRPC) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,20 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/ozline/tiktok/pkg/constants" | ||
"testing" | ||
|
||
"github.com/cloudwego/kitex/client" | ||
"github.com/ozline/tiktok/kitex_gen/user/userservice" | ||
"github.com/ozline/tiktok/pkg/constants" | ||
) | ||
|
||
var conn userservice.Client | ||
var token string | ||
|
||
func TestMain(m *testing.M) { | ||
// 连接服务器 | ||
c, err := userservice.NewClient("user", | ||
func testRPC(t *testing.T) { | ||
_, err := userservice.NewClient("user", | ||
client.WithMuxConnection(constants.MuxConnection), | ||
client.WithHostPorts("0.0.0.0:8888")) | ||
client.WithHostPorts("0.0.0.0:10002")) | ||
|
||
if err != nil { | ||
panic(err) | ||
t.Error(err) | ||
t.Fail() | ||
} | ||
|
||
conn = c | ||
m.Run() | ||
} |