本文整理匯總了Golang中github.com/facebookgo/ensure.PanicDeepEqual函數的典型用法代碼示例。如果您正苦於以下問題:Golang PanicDeepEqual函數的具體用法?Golang PanicDeepEqual怎麽用?Golang PanicDeepEqual使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了PanicDeepEqual函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestClosePoolSizeUndefined
func TestClosePoolSizeUndefined(t *testing.T) {
t.Parallel()
defer ensure.PanicDeepEqual(t, "no close pool size configured")
(&Pool{
Max: 1,
IdleTimeout: time.Second,
}).Acquire()
}
示例2: TestRunNoArgsWithArg
func TestRunNoArgsWithArg(t *testing.T) {
t.Parallel()
h := newHarness(t)
defer h.Stop()
h.env.Exit = func(i int) { panic(exitCode(i)) }
func() {
defer ensure.PanicDeepEqual(t, exitCode(1))
r := runNoArgs(h.env, nil)
r(noOpCmd(), []string{"foo"})
}()
ensure.StringContains(t, h.Err.String(), "unexpected arguments")
}
示例3: TestRunNoArgsFuncError
func TestRunNoArgsFuncError(t *testing.T) {
t.Parallel()
const message = "hello world"
h := newHarness(t)
defer h.Stop()
h.env.Exit = func(i int) { panic(exitCode(i)) }
func() {
defer ensure.PanicDeepEqual(t, exitCode(1))
r := runNoArgs(h.env, func(*env) error { return errors.New(message) })
r(noOpCmd(), nil)
}()
ensure.StringContains(t, h.Err.String(), message)
}
示例4: TestPanicDeepEqualFailure
func TestPanicDeepEqualFailure(t *testing.T) {
var c capture
func() {
defer ensure.PanicDeepEqual(&c, 1)
panic(2)
}()
c.Contains(t, `TestPanicDeepEqualFailure
expected these to be equal:
ACTUAL:
(int) 2
EXPECTED:
(int) 1`)
}
示例5: TestRunWithAppNotFound
func TestRunWithAppNotFound(t *testing.T) {
t.Parallel()
h := newHarness(t)
defer h.Stop()
c := legacyConfig{Applications: map[string]*parseAppConfig{"a": {}}}
h.makeWithConfig(jsonStr(t, c))
h.env.Exit = func(i int) { panic(exitCode(i)) }
func() {
defer ensure.PanicDeepEqual(t, exitCode(1))
r := runWithClient(h.env, nil)
r(noOpCmd(), []string{"b"})
}()
ensure.StringContains(t, h.Err.String(), `App "b" wasn't found`)
}
示例6: TestPanicDeepEqualFailure
func TestPanicDeepEqualFailure(t *testing.T) {
var c capture
func() {
defer ensure.PanicDeepEqual(&c, 1)
panic(2)
}()
c.Matches(t, `TestPanicDeepEqualFailure((.func1)?)
expected these to be equal:
ACTUAL:
\(int\) 2
EXPECTED:
\(int\) 1`)
}
示例7: TestDiscardInvalid
func TestDiscardInvalid(t *testing.T) {
t.Parallel()
defer ensure.PanicDeepEqual(t, errWrongPool)
var cm resourceMaker
p := Pool{
New: cm.New,
Max: 1,
MinIdle: 1,
IdleTimeout: time.Hour,
ClosePoolSize: 1,
}
r, err := cm.New()
ensure.Nil(t, err)
p.Discard(r)
}
示例8: TestRunWithAppMultipleArgs
func TestRunWithAppMultipleArgs(t *testing.T) {
t.Parallel()
h := newHarness(t)
defer h.Stop()
h.env.Exit = func(i int) { panic(exitCode(i)) }
func() {
defer ensure.PanicDeepEqual(t, exitCode(1))
r := runWithClient(h.env, nil)
r(noOpCmd(), []string{"foo", "bar"})
}()
ensure.StringContains(
t,
h.Err.String(),
"only an optional app name is expected",
)
}
示例9: TestRunWithAppNonProjectDir
func TestRunWithAppNonProjectDir(t *testing.T) {
t.Parallel()
h := newHarness(t)
defer h.Stop()
h.makeEmptyRoot()
h.env.Exit = func(i int) { panic(exitCode(i)) }
func() {
defer ensure.PanicDeepEqual(t, exitCode(1))
r := runWithClient(h.env, nil)
r(noOpCmd(), nil)
}()
ensure.StringContains(
t,
h.Err.String(),
"Command must be run inside a Parse project.",
)
}
示例10: TestRunWithAppError
func TestRunWithAppError(t *testing.T) {
t.Parallel()
h := newHarness(t)
defer h.Stop()
const appName = "a"
c := &parseConfig{
Applications: map[string]*parseAppConfig{
appName: {ApplicationID: "id", MasterKey: "token"},
},
}
h.makeWithConfig(jsonStr(t, c))
h.env.Exit = func(i int) { panic(exitCode(i)) }
const message = "hello world"
func() {
defer ensure.PanicDeepEqual(t, exitCode(1))
r := runWithClient(h.env, func(e *env, c *context) error {
ensure.NotNil(t, c)
return errors.New(message)
})
r(noOpCmd(), []string{"a"})
}()
ensure.StringContains(t, h.Err.String(), message)
}
示例11: TestSentinelCloserPanic
func TestSentinelCloserPanic(t *testing.T) {
defer ensure.PanicDeepEqual(t, "should never get called")
sentinelCloser(0).Close()
}
示例12: TestIdleTimeoutUndefined
func TestIdleTimeoutUndefined(t *testing.T) {
t.Parallel()
defer ensure.PanicDeepEqual(t, "no idle timeout configured")
(&Pool{Max: 1}).Acquire()
}
示例13: TestPanicDeepEqualSuccess
func TestPanicDeepEqualSuccess(t *testing.T) {
defer ensure.PanicDeepEqual(t, 1)
panic(1)
}
示例14: TestPanicDeepEqualNil
func TestPanicDeepEqualNil(t *testing.T) {
defer ensure.PanicDeepEqual(t, "can't pass nil to ensure.PanicDeepEqual")
ensure.PanicDeepEqual(t, nil)
}
示例15: TestAddMoreThanLimit
func TestAddMoreThanLimit(t *testing.T) {
defer ensure.PanicDeepEqual(t, "delta greater than limit")
limitgroup.NewLimitGroup(1).Add(2)
}