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


Golang gspec.New函數代碼示例

本文整理匯總了Golang中github.com/viki-org/gspec.New函數的典型用法代碼示例。如果您正苦於以下問題:Golang New函數的具體用法?Golang New怎麽用?Golang New使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了New函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: TestSetsTheBodyPoolSize

func TestSetsTheBodyPoolSize(t *testing.T) {
	spec := gspec.New(t)
	c := Configure().BodyPool(10, 16)
	//allocate 1 extra byte so we know if the body is too large (or just right)
	spec.Expect(c.maxBodySize).ToEqual(int64(17))
	spec.Expect(c.bodyPoolSize).ToEqual(10)
}
開發者ID:viki-org,項目名稱:auwfg,代碼行數:7,代碼來源:configuration_test.go

示例2: TestInvalidWhenStringLengthIsOutsideLen

func TestInvalidWhenStringLengthIsOutsideLen(t *testing.T) {
	spec := gspec.New(t)
	rule := Len(4, 6)
	for _, str := range []string{"123", "12", "1234567", "12345678"} {
		spec.Expect(rule.Verify(str)).ToEqual(false)
	}
}
開發者ID:viki-org,項目名稱:auwfg,代碼行數:7,代碼來源:len_test.go

示例3: TestSetsTheNotFoundResponse

func TestSetsTheNotFoundResponse(t *testing.T) {
	spec := gspec.New(t)
	expected := Json("the res").Status(244).Response
	actual := Configure().NotFoundResponse(expected).notFound
	spec.Expect(actual.GetStatus()).ToEqual(244)
	spec.Expect(string(actual.GetBody())).ToEqual("the res")
}
開發者ID:viki-org,項目名稱:auwfg,代碼行數:7,代碼來源:configuration_test.go

示例4: TestMultipleRanges

func TestMultipleRanges(t *testing.T) {
	spec := gspec.New(t)
	ranges := ParseRange("bytes=7-8,17-100")
	spec.Expect(len(ranges)).ToEqual(2)
	spec.Expect(ranges[0]).ToEqual(*&Range{7, 8})
	spec.Expect(ranges[1]).ToEqual(*&Range{17, 100})
}
開發者ID:karlseguin,項目名稱:seedcdn,代碼行數:7,代碼來源:range_test.go

示例5: TestInvalidWhenStringIsTooShort

func TestInvalidWhenStringIsTooShort(t *testing.T) {
	spec := gspec.New(t)
	rule := MinLen(4)
	for _, str := range []string{"1", "12", "123"} {
		spec.Expect(rule.Verify(str)).ToEqual(false)
	}
}
開發者ID:viki-org,項目名稱:auwfg,代碼行數:7,代碼來源:minlen_test.go

示例6: TestCreatesARequestWithTheCorrectRange

func TestCreatesARequestWithTheCorrectRange(t *testing.T) {
	spec := gspec.New(t)
	context := core.NewContext(gspec.Request().Url("somefile.mp4").Req)
	context.Chunk = 3
	req := newRequest(context, &core.Config{RangedExtensions: map[string]bool{".mp4": true}})
	spec.Expect(req.Header.Get("range")).ToEqual("bytes=6291456-8388607")
}
開發者ID:karlseguin,項目名稱:seedcdn,代碼行數:7,代碼來源:proxy_test.go

示例7: TestGetReturnsTheItemWithEmptySecondaryKey

func TestGetReturnsTheItemWithEmptySecondaryKey(t *testing.T) {
	spec := gspec.New(t)
	c := New(Configure())
	item := NewItem("SAMPLE BODY FOR TESTING")
	c.Set("the-p", "", item)
	spec.Expect(c.Get("the-p", "")).ToEqual(item)
}
開發者ID:viki-org,項目名稱:lrucache,代碼行數:7,代碼來源:lrucache_test.go

示例8: TestValidWhenStringIsShorterThanMaxLen

func TestValidWhenStringIsShorterThanMaxLen(t *testing.T) {
	spec := gspec.New(t)
	rule := MaxLen(4)
	for _, str := range []string{"1", "12", "123", "1234"} {
		spec.Expect(rule.Verify(str)).ToEqual(true)
	}
}
開發者ID:viki-org,項目名稱:auwfg,代碼行數:7,代碼來源:maxlen_test.go

示例9: TestIgnoresTheRangeForNonRangeTypes

func TestIgnoresTheRangeForNonRangeTypes(t *testing.T) {
	spec := gspec.New(t)
	context := core.NewContext(gspec.Request().Url("somefile.mp4").Req)
	context.Chunk = 3
	req := newRequest(context, new(core.Config))
	spec.Expect(req.Header.Get("range")).ToEqual("")
}
開發者ID:karlseguin,項目名稱:seedcdn,代碼行數:7,代碼來源:proxy_test.go

示例10: TestLoadsAConfiguration

func TestLoadsAConfiguration(t *testing.T) {
	spec := gspec.New(t)
	loadConfig([]byte(`{"listen":"1.123.58.13:9001", "upstream":"its.over.net"}`))
	config := GetConfig()
	spec.Expect(config.Listen).ToEqual("1.123.58.13:9001")
	spec.Expect(config.Upstream).ToEqual("its.over.net")
}
開發者ID:karlseguin,項目名稱:seedcdn,代碼行數:7,代碼來源:config_test.go

示例11: TestCreatesARequestWithTheCorrectHostAndUrl

func TestCreatesARequestWithTheCorrectHostAndUrl(t *testing.T) {
	spec := gspec.New(t)
	context := core.NewContext(gspec.Request().Url("/test.json").Req)
	req := newRequest(context, &core.Config{Upstream: "s3.viki.com"})
	spec.Expect(req.Host).ToEqual("s3.viki.com")
	spec.Expect(req.URL.Path).ToEqual("/test.json")
}
開發者ID:karlseguin,項目名稱:seedcdn,代碼行數:7,代碼來源:proxy_test.go

示例12: TestValidWhenStringIsLongerThanMinLen

func TestValidWhenStringIsLongerThanMinLen(t *testing.T) {
	spec := gspec.New(t)
	rule := MinLen(4)
	for _, str := range []string{"1234", "12345", "123456"} {
		spec.Expect(rule.Verify(str)).ToEqual(true)
	}
}
開發者ID:viki-org,項目名稱:auwfg,代碼行數:7,代碼來源:minlen_test.go

示例13: TestInvalidWhenStringIsTooLong

func TestInvalidWhenStringIsTooLong(t *testing.T) {
	spec := gspec.New(t)
	rule := MaxLen(4)
	for _, str := range []string{"12345", "123456"} {
		spec.Expect(rule.Verify(str)).ToEqual(false)
	}
}
開發者ID:viki-org,項目名稱:auwfg,代碼行數:7,代碼來源:maxlen_test.go

示例14: TestValidWhenStringLengthIsWithinLen

func TestValidWhenStringLengthIsWithinLen(t *testing.T) {
	spec := gspec.New(t)
	rule := Len(4, 6)
	for _, str := range []string{"1234", "12345", "123456"} {
		spec.Expect(rule.Verify(str)).ToEqual(true)
	}
}
開發者ID:viki-org,項目名稱:auwfg,代碼行數:7,代碼來源:len_test.go

示例15: TestAddingMultipleSimpleRoutes

func TestAddingMultipleSimpleRoutes(t *testing.T) {
	spec := gspec.New(t)
	c := Configure().
		Route(R("GET", "v1", "gholas", "getgholas")).
		Route(R("LIST", "v1", "gholas", "listgholas"))
	spec.Expect(c.routes["v1"]["gholas"]["GET"].Action.(string)).ToEqual("getgholas")
	spec.Expect(c.routes["v1"]["gholas"]["LIST"].Action.(string)).ToEqual("listgholas")
}
開發者ID:viki-org,項目名稱:auwfg,代碼行數:8,代碼來源:configuration_test.go


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