forked from ebhomengo/niki
1
0
Fork 0

Refactor(benefactor-kindBoxReqs-test): use more feature of suit

Addressed #140

Signed-off-by: Reza Mobaraki <rezam578@gmail.com>
This commit is contained in:
Reza Mobaraki 2024-08-24 14:11:08 +03:30
parent ceab112d0e
commit 38677a0128
No known key found for this signature in database
GPG Key ID: 922CBCF25B541A6F
1 changed files with 7 additions and 5 deletions

View File

@ -32,6 +32,11 @@ type BenefactorKindBoxReqsTestSuite struct {
updateData benefactorkindboxreqparam.KindBoxReqUpdateRequest updateData benefactorkindboxreqparam.KindBoxReqUpdateRequest
} }
// TestBenefactorKindBoxReqsTestSuite is the entry point for the test suite
func TestBenefactorKindBoxReqsTestSuite(t *testing.T) {
suite.Run(t, new(BenefactorKindBoxReqsTestSuite))
}
// SetupTest runs before each test in the suite // SetupTest runs before each test in the suite
func (suite *BenefactorKindBoxReqsTestSuite) SetupTest() { func (suite *BenefactorKindBoxReqsTestSuite) SetupTest() {
teardown := setup.SeedMariaDB(testContainer.GetMariaDBConfig()) teardown := setup.SeedMariaDB(testContainer.GetMariaDBConfig())
@ -71,6 +76,7 @@ func (suite *BenefactorKindBoxReqsTestSuite) SetupTest() {
} }
// loginBenefactor authenticates the benefactor and returns an access token // loginBenefactor authenticates the benefactor and returns an access token
// TODO: Move this to a common utility function
func (suite *BenefactorKindBoxReqsTestSuite) loginBenefactor() string { func (suite *BenefactorKindBoxReqsTestSuite) loginBenefactor() string {
sendOTPRes, err := services.BenefactorSvc.SendOtp(context.Background(), benefactoreparam.SendOtpRequest{ sendOTPRes, err := services.BenefactorSvc.SendOtp(context.Background(), benefactoreparam.SendOtpRequest{
PhoneNumber: suite.benefactorPhone, PhoneNumber: suite.benefactorPhone,
@ -87,6 +93,7 @@ func (suite *BenefactorKindBoxReqsTestSuite) loginBenefactor() string {
} }
// createRequest is a utility function to create and send HTTP requests // createRequest is a utility function to create and send HTTP requests
// TODO: Move this to a common utility function
func (suite *BenefactorKindBoxReqsTestSuite) createRequest(method, url string, body interface{}) *httptest.ResponseRecorder { func (suite *BenefactorKindBoxReqsTestSuite) createRequest(method, url string, body interface{}) *httptest.ResponseRecorder {
var buf bytes.Buffer var buf bytes.Buffer
if body != nil { if body != nil {
@ -190,8 +197,3 @@ func (suite *BenefactorKindBoxReqsTestSuite) TestBenefactorKindBoxReqs_Delete_Su
) )
suite.Require().Error(err) suite.Require().Error(err)
} }
// TestBenefactorKindBoxReqsTestSuite is the entry point for the test suite
func TestBenefactorKindBoxReqsTestSuite(t *testing.T) {
suite.Run(t, new(BenefactorKindBoxReqsTestSuite))
}