1
0
mirror of https://github.com/volatiletech/authboss.git synced 2024-11-28 08:58:38 +02:00
authboss/values_test.go
Aaron L c38f79490b Increase testing coverage.
- Missed some actual tests, added them.
- Added a bunch of useless tests to increase coverage. Guilty as
  charged.
2018-05-14 14:27:33 -07:00

71 lines
1.7 KiB
Go

package authboss
import "testing"
type testAssertionValues struct{}
func (testAssertionValues) Validate() []error { return nil }
func (testAssertionValues) GetPID() string { return "" }
func (testAssertionValues) GetPassword() string { return "" }
func (testAssertionValues) GetToken() string { return "" }
func (testAssertionValues) GetShouldRemember() bool { return false }
func (testAssertionValues) GetValues() map[string]string { return nil }
type testAssertionFailValues struct{}
func (testAssertionFailValues) Validate() []error { return nil }
func TestValueAssertions(t *testing.T) {
t.Parallel()
v := testAssertionValues{}
fv := testAssertionFailValues{}
paniced := false
func() {
defer func() {
if r := recover(); r != nil {
paniced = true
}
}()
MustHaveUserValues(v)
MustHaveConfirmValues(v)
MustHaveRecoverStartValues(v)
MustHaveRecoverMiddleValues(v)
MustHaveRecoverEndValues(v)
}()
if paniced {
t.Error("The mock storer should have included all interfaces and should not panic")
}
didPanic := func(f func()) (paniced bool) {
defer func() {
if r := recover(); r != nil {
paniced = true
}
}()
f()
return paniced
}
if !didPanic(func() { MustHaveUserValues(fv) }) {
t.Error("should have panic'd")
}
if !didPanic(func() { MustHaveConfirmValues(fv) }) {
t.Error("should have panic'd")
}
if !didPanic(func() { MustHaveRecoverStartValues(fv) }) {
t.Error("should have panic'd")
}
if !didPanic(func() { MustHaveRecoverMiddleValues(fv) }) {
t.Error("should have panic'd")
}
if !didPanic(func() { MustHaveRecoverEndValues(fv) }) {
t.Error("should have panic'd")
}
}