补充readme

This commit is contained in:
yumaojun03 2025-05-11 16:28:20 +08:00
parent a1bd181212
commit 91acab4489

View File

@ -5,4 +5,32 @@
## 单元测试 (TDD) ## 单元测试 (TDD)
```go
func TestGetBook(t *testing.T) {
book, err := controllers.Book.GetBook(context.Background(), controllers.NewGetBookRequest(3))
if err != nil {
t.Fatal(err)
}
t.Log(book)
}
func TestCreateBook(t *testing.T) {
book, err := controllers.Book.CreateBook(context.Background(), &models.BookSpec{
Title: "unit test for go controller obj",
Author: "will",
Price: 99.99,
})
if err != nil {
t.Fatal(err)
}
t.Log(book)
}
func init() {
// 执行配置的加载
err := config.LoadConfigFromYaml(fmt.Sprintf("%s/book/v3/application.yaml", os.Getenv("workspaceFolder")))
if err != nil {
panic(err)
}
}
```