forked from forgejo/forgejo
Added all required dependencies
This commit is contained in:
parent
78f86abba4
commit
1ebb35b988
660 changed files with 502447 additions and 0 deletions
115
vendor/github.com/smartystreets/assertions/panic.go
generated
vendored
Normal file
115
vendor/github.com/smartystreets/assertions/panic.go
generated
vendored
Normal file
|
@ -0,0 +1,115 @@
|
|||
package assertions
|
||||
|
||||
import "fmt"
|
||||
|
||||
// ShouldPanic receives a void, niladic function and expects to recover a panic.
|
||||
func ShouldPanic(actual interface{}, expected ...interface{}) (message string) {
|
||||
if fail := need(0, expected); fail != success {
|
||||
return fail
|
||||
}
|
||||
|
||||
action, _ := actual.(func())
|
||||
|
||||
if action == nil {
|
||||
message = shouldUseVoidNiladicFunction
|
||||
return
|
||||
}
|
||||
|
||||
defer func() {
|
||||
recovered := recover()
|
||||
if recovered == nil {
|
||||
message = shouldHavePanicked
|
||||
} else {
|
||||
message = success
|
||||
}
|
||||
}()
|
||||
action()
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// ShouldNotPanic receives a void, niladic function and expects to execute the function without any panic.
|
||||
func ShouldNotPanic(actual interface{}, expected ...interface{}) (message string) {
|
||||
if fail := need(0, expected); fail != success {
|
||||
return fail
|
||||
}
|
||||
|
||||
action, _ := actual.(func())
|
||||
|
||||
if action == nil {
|
||||
message = shouldUseVoidNiladicFunction
|
||||
return
|
||||
}
|
||||
|
||||
defer func() {
|
||||
recovered := recover()
|
||||
if recovered != nil {
|
||||
message = fmt.Sprintf(shouldNotHavePanicked, recovered)
|
||||
} else {
|
||||
message = success
|
||||
}
|
||||
}()
|
||||
action()
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// ShouldPanicWith receives a void, niladic function and expects to recover a panic with the second argument as the content.
|
||||
func ShouldPanicWith(actual interface{}, expected ...interface{}) (message string) {
|
||||
if fail := need(1, expected); fail != success {
|
||||
return fail
|
||||
}
|
||||
|
||||
action, _ := actual.(func())
|
||||
|
||||
if action == nil {
|
||||
message = shouldUseVoidNiladicFunction
|
||||
return
|
||||
}
|
||||
|
||||
defer func() {
|
||||
recovered := recover()
|
||||
if recovered == nil {
|
||||
message = shouldHavePanicked
|
||||
} else {
|
||||
if equal := ShouldEqual(recovered, expected[0]); equal != success {
|
||||
message = serializer.serialize(expected[0], recovered, fmt.Sprintf(shouldHavePanickedWith, expected[0], recovered))
|
||||
} else {
|
||||
message = success
|
||||
}
|
||||
}
|
||||
}()
|
||||
action()
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// ShouldNotPanicWith receives a void, niladic function and expects to recover a panic whose content differs from the second argument.
|
||||
func ShouldNotPanicWith(actual interface{}, expected ...interface{}) (message string) {
|
||||
if fail := need(1, expected); fail != success {
|
||||
return fail
|
||||
}
|
||||
|
||||
action, _ := actual.(func())
|
||||
|
||||
if action == nil {
|
||||
message = shouldUseVoidNiladicFunction
|
||||
return
|
||||
}
|
||||
|
||||
defer func() {
|
||||
recovered := recover()
|
||||
if recovered == nil {
|
||||
message = success
|
||||
} else {
|
||||
if equal := ShouldEqual(recovered, expected[0]); equal == success {
|
||||
message = fmt.Sprintf(shouldNotHavePanickedWith, expected[0])
|
||||
} else {
|
||||
message = success
|
||||
}
|
||||
}
|
||||
}()
|
||||
action()
|
||||
|
||||
return
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue