當前位置: 首頁>>代碼示例>>Golang>>正文


Golang ensure.PanicDeepEqual函數代碼示例

本文整理匯總了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()
}
開發者ID:intercom,項目名稱:dvara,代碼行數:8,代碼來源:rpool_test.go

示例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")
}
開發者ID:hassanabidpk,項目名稱:parse-cli,代碼行數:12,代碼來源:main_test.go

示例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)
}
開發者ID:hassanabidpk,項目名稱:parse-cli,代碼行數:13,代碼來源:main_test.go

示例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`)
}
開發者ID:fwessels,項目名稱:minio-xl,代碼行數:14,代碼來源:ensure_test.go

示例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`)
}
開發者ID:hassanabidpk,項目名稱:parse-cli,代碼行數:14,代碼來源:main_test.go

示例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`)
}
開發者ID:thomasf,項目名稱:alkasir,代碼行數:14,代碼來源:ensure_test.go

示例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)
}
開發者ID:intercom,項目名稱:dvara,代碼行數:15,代碼來源:rpool_test.go

示例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",
	)
}
開發者ID:hassanabidpk,項目名稱:parse-cli,代碼行數:16,代碼來源:main_test.go

示例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.",
	)
}
開發者ID:hassanabidpk,項目名稱:parse-cli,代碼行數:17,代碼來源:main_test.go

示例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)
}
開發者ID:hassanabidpk,項目名稱:parse-cli,代碼行數:23,代碼來源:main_test.go

示例11: TestSentinelCloserPanic

func TestSentinelCloserPanic(t *testing.T) {
	defer ensure.PanicDeepEqual(t, "should never get called")
	sentinelCloser(0).Close()
}
開發者ID:intercom,項目名稱:dvara,代碼行數:4,代碼來源:rpool_test_internals.go

示例12: TestIdleTimeoutUndefined

func TestIdleTimeoutUndefined(t *testing.T) {
	t.Parallel()
	defer ensure.PanicDeepEqual(t, "no idle timeout configured")
	(&Pool{Max: 1}).Acquire()
}
開發者ID:intercom,項目名稱:dvara,代碼行數:5,代碼來源:rpool_test.go

示例13: TestPanicDeepEqualSuccess

func TestPanicDeepEqualSuccess(t *testing.T) {
	defer ensure.PanicDeepEqual(t, 1)
	panic(1)
}
開發者ID:thomasf,項目名稱:alkasir,代碼行數:4,代碼來源:ensure_test.go

示例14: TestPanicDeepEqualNil

func TestPanicDeepEqualNil(t *testing.T) {
	defer ensure.PanicDeepEqual(t, "can't pass nil to ensure.PanicDeepEqual")
	ensure.PanicDeepEqual(t, nil)
}
開發者ID:thomasf,項目名稱:alkasir,代碼行數:4,代碼來源:ensure_test.go

示例15: TestAddMoreThanLimit

func TestAddMoreThanLimit(t *testing.T) {
	defer ensure.PanicDeepEqual(t, "delta greater than limit")
	limitgroup.NewLimitGroup(1).Add(2)
}
開發者ID:postfix,項目名稱:limitgroup,代碼行數:4,代碼來源:limitgroup_test.go


注:本文中的github.com/facebookgo/ensure.PanicDeepEqual函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。