Skip to main content

撰寫http request 的複雜一點的測試

在接下來的內容,要將測試案例在變得更多

測試案例

在建立資料的部分,如果輸入正確資料,則回成功 如果資料不對,回傳400並跟使用者說明錯在哪裡

如果未來需要針對每個屬性來進行說明,在這邊會需要一個使用到go-playground/validator的功能 https://raw.githubusercontent.com/go-playground/validator/master/_examples/translations/main.go 這段內容是可以將透過validator的錯誤透過這個validator來進行轉換,來讓使用者知道自己輸入的內容還缺了什麼

在這邊是這次的code跟轉寫的影片 https://youtu.be/hmf_BzRe0Mw

https://github.com/kevinyay945/smart-home-backend/tree/v0.5.3