added new membership tests, fix tests, cors for dev
This commit is contained in:
@@ -28,11 +28,11 @@ type RegisterUserTest struct {
|
||||
Assert bool
|
||||
}
|
||||
|
||||
func (rt *RegisterUserTest) SetupContext() (*gin.Context, *httptest.ResponseRecorder) {
|
||||
func (rt *RegisterUserTest) SetupContext() (*gin.Context, *httptest.ResponseRecorder, *gin.Engine) {
|
||||
return GetMockedJSONContext([]byte(rt.Input), "register")
|
||||
}
|
||||
|
||||
func (rt *RegisterUserTest) RunHandler(c *gin.Context) {
|
||||
func (rt *RegisterUserTest) RunHandler(c *gin.Context, router *gin.Engine) {
|
||||
Uc.RegisterUser(c)
|
||||
}
|
||||
|
||||
@@ -215,7 +215,7 @@ func checkVerificationMail(message *utils.Email, user *models.User) error {
|
||||
func verifyMail(verificationURL string) error {
|
||||
gin.SetMode(gin.TestMode)
|
||||
router := gin.New()
|
||||
router.LoadHTMLGlob(filepath.Join(config.Templates.HTMLPath, "*")) // Adjust the path to your HTML templates
|
||||
router.LoadHTMLGlob(filepath.Join(config.Templates.HTMLPath, "*"))
|
||||
|
||||
router.GET("/backend/verify", Uc.VerifyMailHandler)
|
||||
wv := httptest.NewRecorder()
|
||||
@@ -413,5 +413,40 @@ func getTestUsers() []RegisterUserTest {
|
||||
return user
|
||||
})),
|
||||
},
|
||||
{
|
||||
Name: "Subscription constraints not entered; should fail",
|
||||
WantResponse: http.StatusNotAcceptable,
|
||||
WantDBData: map[string]interface{}{"Email": "john.junior.doe@example.com"},
|
||||
Assert: false,
|
||||
Input: GenerateInputJSON(customizeInput(func(user models.User) models.User {
|
||||
user.Email = "john.junior.doe@example.com"
|
||||
user.Membership.SubscriptionModel.Name = "additional"
|
||||
return user
|
||||
})),
|
||||
},
|
||||
{
|
||||
Name: "Subscription constraints wrong; should fail",
|
||||
WantResponse: http.StatusNotAcceptable,
|
||||
WantDBData: map[string]interface{}{"Email": "john.junior.doe@example.com"},
|
||||
Assert: false,
|
||||
Input: GenerateInputJSON(customizeInput(func(user models.User) models.User {
|
||||
user.Email = "john.junior.doe@example.com"
|
||||
user.Membership.ParentMembershipID = 200
|
||||
user.Membership.SubscriptionModel.Name = "additional"
|
||||
return user
|
||||
})),
|
||||
},
|
||||
{
|
||||
Name: "Subscription constraints correct, should pass",
|
||||
WantResponse: http.StatusCreated,
|
||||
WantDBData: map[string]interface{}{"Email": "john.junior.doe@example.com"},
|
||||
Assert: true,
|
||||
Input: GenerateInputJSON(customizeInput(func(user models.User) models.User {
|
||||
user.Email = "john.junior.doe@example.com"
|
||||
user.Membership.ParentMembershipID = 1
|
||||
user.Membership.SubscriptionModel.Name = "additional"
|
||||
return user
|
||||
})),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user