Skip to content

Commit

Permalink
Fixing the test logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan Kueh committed Dec 3, 2020
1 parent 6e7cbda commit d88f45e
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@ package main
import "testing"

func TestEmptyOTP(t *testing.T) {
if valid, err := oneTimePasscodeIsValid(""); err != nil {
t.Errorf("Empty OTP triggered error: %s", err)
if valid, err := oneTimePasscodeIsValid(""); err == nil {
t.Errorf("Empty OTP triggered did not trigger error as expected: %s", err)
} else if valid {
t.Errorf("Empty OTP passed validation")
}
}

func TestAlphabetOTP(t *testing.T) {
if valid, err := oneTimePasscodeIsValid("hunter2"); err != nil {
t.Errorf("Invalid (alphabetical) OTP triggered error: %s", err)
if valid, err := oneTimePasscodeIsValid("hunter2"); err == nil {
t.Errorf("Invalid (alphabetical) OTP did not trigger error as expected: %s", err)
} else if valid {
t.Errorf("Invalid (alphabetical) OTP passed validation")
}
}

func TestShortOTP(t *testing.T) {
if valid, err := oneTimePasscodeIsValid("42069"); err != nil {
t.Errorf("Invalid (short) OTP threw error: %s", err)
if valid, err := oneTimePasscodeIsValid("42069"); err == nil {
t.Errorf("Invalid (short) OTP did not trigger error as expected: %s", err)
} else if valid {
t.Errorf("Invalid (short) OTP passed validation")
}
Expand Down

0 comments on commit d88f45e

Please sign in to comment.