-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: adding validate check tov validate password request payload
- Loading branch information
1 parent
7e9a7d5
commit 29273b3
Showing
3 changed files
with
60 additions
and
3 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
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 |
---|---|---|
|
@@ -59,3 +59,46 @@ func TestLoginUserPayload_Validate(t *testing.T) { | |
}) | ||
} | ||
} | ||
|
||
func TestResetPasswordPayload_Validate(t *testing.T) { | ||
type args struct { | ||
payload PasswordResetPayload | ||
} | ||
|
||
tests := []struct { | ||
name string | ||
args args | ||
wantErr bool | ||
}{ | ||
{ | ||
name: "Happy case: valid payload", | ||
args: args{ | ||
payload: PasswordResetPayload{ | ||
Email: "[email protected]", | ||
Variant: "UzaziSalamaProd", | ||
Origin: "https://localhost:test.com", | ||
}, | ||
}, | ||
wantErr: false, | ||
}, | ||
{ | ||
name: "Sad case: invalid email", | ||
args: args{ | ||
payload: PasswordResetPayload{ | ||
Email: "testuserexample", | ||
Variant: "UzaziSalamaProd", | ||
Origin: "https://localhost:test.com", | ||
}, | ||
}, | ||
wantErr: true, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
p := tt.args.payload | ||
if err := p.Validate(); (err != nil) != tt.wantErr { | ||
t.Errorf("PasswordResetPayload.Validate() error = %v, wantErr %v", err, tt.wantErr) | ||
} | ||
}) | ||
} | ||
} |