Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests to verify password functionality
- Loading branch information
Showing
2 changed files
with
49 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package main | ||
|
||
import ( | ||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
var _ = Describe("password", func() { | ||
var ( | ||
badPassword password | ||
goodPassword password | ||
) | ||
|
||
BeforeEach(func() { | ||
badPassword = password{Password: "-badpassword", Upper: 0, Lower: 11, Number: 0, Special: 1} | ||
goodPassword = password{Password: "goodpassword", Upper: 0, Lower: 12, Number: 0, Special: 0} | ||
}) | ||
|
||
Describe("Password generation", func() { | ||
Context("With a leading dash", func() { | ||
It("should generate a new password", func() { | ||
Expect(ValidatePassword(badPassword)).To(MatchError("Invalid password")) | ||
}) | ||
}) | ||
Context("Without a leading dash", func() { | ||
It("should accept the password", func() { | ||
Expect(ValidatePassword(goodPassword)).To(BeNil()) | ||
}) | ||
}) | ||
}) | ||
}) |