本文整理匯總了Golang中testing.T.Use方法的典型用法代碼示例。如果您正苦於以下問題:Golang T.Use方法的具體用法?Golang T.Use怎麽用?Golang T.Use使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類testing.T
的用法示例。
在下文中一共展示了T.Use方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Test_LedisCacher
func Test_LedisCacher(t *testing.T) {
Convey("Test ledis cache adapter", t, func() {
opt := cache.Options{
Adapter: "ledis",
AdapterConfig: "data_dir=./tmp.db",
Interval: 1,
}
Convey("Basic operations", func() {
t := tango.New()
t.Use(cache.New(opt))
t.Get("/", new(CacheAction))
resp := httptest.NewRecorder()
req, err := http.NewRequest("GET", "/", nil)
So(err, ShouldBeNil)
t.ServeHTTP(resp, req)
t.Get("/id", new(Cache2Action))
resp = httptest.NewRecorder()
req, err = http.NewRequest("GET", "/id", nil)
So(err, ShouldBeNil)
t.ServeHTTP(resp, req)
})
})
}
示例2: Test_PostgresCacher
func Test_PostgresCacher(t *testing.T) {
Convey("Test postgres cache adapter", t, func() {
Convey("Basic operations", func() {
t := tango.New()
t.Use(cache.New(opt))
t.Get("/", new(CacheAction))
resp := httptest.NewRecorder()
req, err := http.NewRequest("GET", "/", nil)
So(err, ShouldBeNil)
t.ServeHTTP(resp, req)
})
Convey("Increase and decrease operations", func() {
t := tango.New()
t.Use(cache.New(opt))
t.Get("/", new(Cache2Action))
resp := httptest.NewRecorder()
req, err := http.NewRequest("GET", "/", nil)
So(err, ShouldBeNil)
t.ServeHTTP(resp, req)
})
})
}
示例3: Test_MemcacheCacher
func Test_MemcacheCacher(t *testing.T) {
Convey("Test memcache cache adapter", t, func() {
opt := cache.Options{
Adapter: "memcache",
AdapterConfig: "127.0.0.1:9090",
}
Convey("Basic operations", func() {
t := tango.New()
t.Use(cache.New(opt))
t.Get("/", new(CacheAction))
resp := httptest.NewRecorder()
req, err := http.NewRequest("GET", "/", nil)
So(err, ShouldBeNil)
t.ServeHTTP(resp, req)
})
Convey("Increase and decrease operations", func() {
t := tango.New()
t.Use(cache.New(opt))
t.Get("/", new(Cache2Action))
resp := httptest.NewRecorder()
req, err := http.NewRequest("GET", "/", nil)
So(err, ShouldBeNil)
t.ServeHTTP(resp, req)
})
})
}
示例4: Test_RedisCacher
func Test_RedisCacher(t *testing.T) {
Convey("Test redis cache adapter", t, func() {
opt := cache.Options{
Adapter: "redis",
AdapterConfig: "addr=:6379,prefix=cache:",
}
Convey("Basic operations", func() {
t := tango.New()
t.Use(cache.New(opt))
t.Get("/", new(CacheAction))
resp := httptest.NewRecorder()
req, err := http.NewRequest("GET", "/", nil)
So(err, ShouldBeNil)
t.ServeHTTP(resp, req)
})
Convey("Increase and decrease operations", func() {
t := tango.New()
t.Use(cache.New(opt))
t.Get("/", new(Cache2Action))
resp := httptest.NewRecorder()
req, err := http.NewRequest("GET", "/", nil)
So(err, ShouldBeNil)
t.ServeHTTP(resp, req)
})
})
}
示例5: Test_Cacher
func Test_Cacher(t *testing.T) {
Convey("Use cache middleware", t, func() {
t := tango.Classic()
t.Use(New())
t.Get("/", new(testCacheController))
resp := httptest.NewRecorder()
req, err := http.NewRequest("GET", "/", nil)
So(err, ShouldBeNil)
t.ServeHTTP(resp, req)
})
Convey("Register invalid adapter", t, func() {
Convey("Adatper not exists", func() {
defer func() {
So(recover(), ShouldNotBeNil)
}()
t := tango.Classic()
t.Use(New(Options{
Adapter: "fake",
}))
})
Convey("Provider value is nil", func() {
defer func() {
So(recover(), ShouldNotBeNil)
}()
Register("fake", nil)
})
Convey("Register twice", func() {
defer func() {
So(recover(), ShouldNotBeNil)
}()
Register("memory", &MemoryCacher{})
})
})
}