• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang assert.Implements函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/stretchr/testify/assert.Implements函数的典型用法代码示例。如果您正苦于以下问题:Golang Implements函数的具体用法?Golang Implements怎么用?Golang Implements使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了Implements函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: TestTextRendererFactory_TestInterface

func TestTextRendererFactory_TestInterface(t *testing.T) {
	var inter *TextRendererFactory

	assert.Implements(t, inter, new(MarkdownTextRendererFactory))
	assert.Implements(t, inter, new(EscapeCodeRendererFactory))
	assert.Implements(t, inter, new(PlainRendererFactory))
}
开发者ID:sguiheux,项目名称:termui,代码行数:7,代码来源:textRender_test.go


示例2: TestJSONStoreImplements

func TestJSONStoreImplements(t *testing.T) {
	t.Parallel()

	j := new(JSONStore)
	assert.Implements(t, (*Storage)(nil), j)
	assert.Implements(t, (*TaskStore)(nil), j)
	assert.Implements(t, (*MetaStore)(nil), j)
	assert.Implements(t, (*MetaTaskStore)(nil), j)
}
开发者ID:godep-migrator,项目名称:finch,代码行数:9,代码来源:json_storage_test.go


示例3: TestInboundsOrderIsMaintained

func TestInboundsOrderIsMaintained(t *testing.T) {
	dispatcher := basicDispatcher(t)

	// Order must be maintained
	assert.Implements(t,
		(*tch.Inbound)(nil), dispatcher.Inbounds()[0], "first inbound must be TChannel")
	assert.Implements(t,
		(*http.Inbound)(nil), dispatcher.Inbounds()[1], "second inbound must be HTTP")
}
开发者ID:yarpc,项目名称:yarpc-go,代码行数:9,代码来源:dispatcher_test.go


示例4: TestGetMeRequest

// TestGetMeRequest tests
func TestGetMeRequest(t *testing.T) {
	assert := assert.New(t)

	assert.Implements((*Parameter)(nil), new(GetMeRequest))
	assert.Implements((*RequestParameter)(nil), new(GetMeRequest))

	var p GetMeRequest
	p = GetMeRequest{}
	_ = p

}
开发者ID:gophergala2016,项目名称:source,代码行数:12,代码来源:me_request_test.go


示例5: TestParserDiffStates

func TestParserDiffStates(t *testing.T) {
	ps := testParseAll(
		t, "tpdifs01", "--time=37", "-nn", "-xplay", "-t", "47", "effie")

	testOpt := (*Option)(nil)
	testStrArr := []string{}

	psArgs := ps.Last()
	assert.NotNil(t, psArgs)
	assert.NotNil(t, psArgs.Value())
	assert.IsType(t, testStrArr, psArgs.Value())
	assert.Len(t, psArgs.Value(), 1)
	assert.Equal(t, "effie", psArgs.Value().([]string)[0])

	psT0 := ps.First()
	assert.NotNil(t, psT0)
	assert.NotNil(t, psT0.Value())
	assert.Implements(t, testOpt, psT0.Value())
	o := psT0.Value().(Option)
	assert.EqualValues(t, 't', o.Opt())
	assert.Equal(t, "37", o.Value())

	psN0, _ := psT0.Next()
	assert.NotNil(t, psN0)
	assert.NotNil(t, psN0.Value())
	assert.Implements(t, testOpt, psN0.Value())
	o = psN0.Value().(Option)
	assert.EqualValues(t, 'n', o.Opt())

	psN1, _ := psN0.Next()
	assert.NotNil(t, psN1)
	assert.NotNil(t, psN1.Value())
	assert.Implements(t, testOpt, psN1.Value())
	o = psN1.Value().(Option)
	assert.EqualValues(t, 'n', o.Opt())

	psX0, _ := psN1.Next()
	assert.NotNil(t, psX0)
	assert.NotNil(t, psX0.Value())
	assert.Implements(t, testOpt, psX0.Value())
	o = psX0.Value().(Option)
	assert.EqualValues(t, 'x', o.Opt())
	assert.Equal(t, "play", o.Value())

	psT1, _ := psX0.Next()
	assert.NotNil(t, psT1)
	assert.NotNil(t, psT1.Value())
	assert.Implements(t, testOpt, psT1.Value())
	o = psT1.Value().(Option)
	assert.EqualValues(t, 't', o.Opt())
	assert.Equal(t, "47", o.Value())
}
开发者ID:akutz,项目名称:gotopt,代码行数:52,代码来源:gotopt_test.go


示例6: TestAvgReducer

func TestAvgReducer(t *testing.T) {
	reducer := &Avg{[]string{"foo", "bar"}}
	assert.Implements(t, (*Reducer)(nil), reducer)

	// Prepare import channel
	input := make(chan *Entry, 2)
	input <- NewEntry(Fields{
		"uri": "/asd/fgh",
		"foo": "123",
		"bar": "234",
		"baz": "345",
	})
	input <- NewEntry(Fields{
		"uri": "/zxc/vbn",
		"foo": "456",
		"bar": "567",
		"baz": "678",
	})
	close(input)
	output := make(chan *Entry, 1) // Make it buffered to avoid deadlock
	reducer.Reduce(input, output)

	result, ok := <-output
	assert.True(t, ok)
	value, err := result.FloatField("foo")
	assert.NoError(t, err)
	assert.Equal(t, value, (123.0+456)/2.0)
	value, err = result.FloatField("bar")
	assert.NoError(t, err)
	assert.Equal(t, value, (234.0+567.0)/2.0)
	_, err = result.Field("buz")
	assert.Error(t, err)
}
开发者ID:zooniverse,项目名称:gonx,代码行数:33,代码来源:reducer_test.go


示例7: TestCreateAndCloseLogger

func TestCreateAndCloseLogger(t *testing.T) {
	tf, err := ioutil.TempFile("", "")
	require.Nil(t, err)

	c := &Config{
		Logger: struct {
			Output, Formatter, Level string
			LogFile                  string `mapstructure:"log_file"`
		}{
			Output:    "both",
			Formatter: "json",
			Level:     "info",
			LogFile:   tf.Name(),
		},
	}

	l, err := NewLogger(c)
	require.Nil(t, err)

	assert.Equal(t, c, l.config)
	assert.Equal(t, tf.Name(), l.file.Name())
	assert.Implements(t, (*io.Writer)(nil), l.Out)
	assert.IsType(t, new(log.JSONFormatter), l.Formatter)
	assert.Equal(t, log.InfoLevel, l.Level)

	_, err = l.file.Stat()
	assert.Nil(t, err)

	l.Close()

	_, err = l.file.Stat()
	assert.NotNil(t, err)
}
开发者ID:beanworks,项目名称:rex,代码行数:33,代码来源:logger_test.go


示例8: TestWatchError

func TestWatchError(t *testing.T) {
	t.Parallel()
	server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
		flusher, ok := w.(http.Flusher)
		require.True(t, ok, "streaming unsupported")

		w.Header().Set("Content-Type", "text/event-stream")
		w.Header().Set("Cache-Control", "no-cache")
		w.Header().Set("Connection", "keep-alive")
		w.Header().Set("Access-Control-Allow-Origin", "*")
		flusher.Flush()
	}))

	var (
		notifications = make(chan Event)
		fb            = New(server.URL)
	)
	defer server.Close()

	if err := fb.Watch(notifications); err != nil {
		t.Fatal(err)
	}

	go server.Close()
	event, ok := <-notifications
	require.True(t, ok, "notifications closed")
	assert.Equal(t, EventTypeError, event.Type, "event type doesn't match")
	assert.Empty(t, event.Path, "event path is not empty")
	assert.NotNil(t, event.Data, "event data is nil")
	assert.Implements(t, new(error), event.Data)
}
开发者ID:alungboy,项目名称:firego,代码行数:31,代码来源:watch_test.go


示例9: TestThenFuncNil

func TestThenFuncNil(t *testing.T) {
	assert := assert.New(t)
	assert.NotPanics(func() {
		final := New().ThenFunc(nil)
		assert.Implements((*http.Handler)(nil), final)
	})
}
开发者ID:singnurkar,项目名称:apollo,代码行数:7,代码来源:chain_test.go


示例10: TestNewStorm

func TestNewStorm(t *testing.T) {
	db, err := Open("")

	assert.Error(t, err)
	assert.Nil(t, db)

	dir, err := ioutil.TempDir(os.TempDir(), "storm")
	assert.NoError(t, err)
	defer os.RemoveAll(dir)

	file := filepath.Join(dir, "storm.db")
	db, err = Open(file)
	defer db.Close()

	assert.Implements(t, (*Node)(nil), db)

	assert.NoError(t, err)
	assert.Equal(t, file, db.Path)
	assert.NotNil(t, db.Bolt)
	assert.Equal(t, defaultCodec, db.Codec())

	var v string
	err = db.Get(dbinfo, "version", &v)
	assert.NoError(t, err)
	assert.Equal(t, Version, v)
}
开发者ID:asdine,项目名称:storm,代码行数:26,代码来源:storm_test.go


示例11: TestFoundationRequest

// TestFoundationRequest runs
func TestFoundationRequest(t *testing.T) {
	assert := assert.New(t)

	var ctx Context = NewContext(gintest.SharedContext())
	o := ctx.Request()
	assert.NotNil(o)
	assert.Implements((*Request)(nil), o)
	assert.NotPanics(func() {
		orgReq := (ctx.(*FoundationContext)).opt.Request
		clnReq := o.Clone()
		assert.NotEqual(fmt.Sprintf("%p", orgReq), fmt.Sprintf("%p", clnReq), "Shouldn't be equal.")
		assert.Equal(orgReq, clnReq, "Should be the same contained object")
		assert.False(o.RequestedAt().IsZero())
		assert.Equal([]byte(""), o.Body())
		assert.Equal([]byte(""), o.Body())
		assert.Equal("/", o.URL().String())
		assert.Equal("GET", o.Method())
		assert.Equal(url.Values{}, o.Query())

		ipAddr := o.ClientIP()
		assert.True(strings.HasPrefix(ipAddr, "127.0.0.1") || strings.HasPrefix(ipAddr, "[::1]"))
		assert.Equal("Go-http-client/1.1", o.UserAgent())
		assert.Equal("", o.Header("foobar"), "Doesn't exist a value of the key")
		assert.Equal(o.UserAgent(), o.Header("User-Agent"), "Doesn't exist a value of the key")

		// X-Forwarded-For
		(ctx.(*FoundationContext)).opt.Request.Header.Set("X-Forwarded-For", "10.0.0.1")
		assert.True(strings.HasPrefix(o.ClientIP(), "10.0.0.1"))

		// X-Real-Ip
		(ctx.(*FoundationContext)).opt.Request.Header.Set("X-Real-Ip", "10.0.0.2")
		assert.True(strings.HasPrefix(o.ClientIP(), "10.0.0.2"))
	})
}
开发者ID:gophergala2016,项目名称:source,代码行数:35,代码来源:context_test.go


示例12: TestEngine

// TestEngine runs
func TestEngine(t *testing.T) {
	assert := assert.New(t)

	var engine *Engine
	assert.Nil(engine)

	engine = New()
	assert.NotNil(engine)

	engine = Default()
	assert.NotNil(engine)

	Middlewares = []Middleware{
		RecoveryMiddleware(),
		RecoveryMiddleware(),
	}
	engine = Default()
	assert.NotNil(engine)

	assert.NotNil(engine.Static("", ""))
	assert.Panics(func() {
		engine.LoadHTMLGlob("", "")
	})

	handler := func(c *gin.Context) {}
	assert.NotNil(engine.Group("/test", handler))
	assert.Implements((*IRoutes)(nil), engine.POST("/test/post", handler))
	assert.Panics(func() {
		// panic: path segment '/' conflicts with existing wildcard '/*filepath' in path '/'
		engine.GET("/test/get", handler)
	})
	assert.Implements((*IRoutes)(nil), engine.DELETE("/test/delete", handler))
	assert.Implements((*IRoutes)(nil), engine.PATCH("/test/patch", handler))
	assert.Implements((*IRoutes)(nil), engine.PUT("/test/put", handler))

	go func() {
		assert.NoError(engine.Run(":8123"))
	}()
	go func() {
		// Because: no such file or directory
		assert.Error(engine.RunTLS(":8133", "cert", "key"))
	}()
	go func() {
		assert.NoError(engine.RunUnix("/tmp/unix.sock"))
	}()
	time.Sleep(100 * time.Millisecond)
}
开发者ID:gophergala2016,项目名称:source,代码行数:48,代码来源:foundation_test.go


示例13: TestFoundationResponse

// TestFoundationResponse runs
func TestFoundationResponse(t *testing.T) {
	assert := assert.New(t)

	var ctx Context = NewContext(gintest.SharedContext())
	o := ctx.Response()
	assert.NotNil(o)
	assert.Implements((*Response)(nil), o)
}
开发者ID:gophergala2016,项目名称:source,代码行数:9,代码来源:context_test.go


示例14: TestThenFuncNoMiddleware

func TestThenFuncNoMiddleware(t *testing.T) {
	assert := assert.New(t)
	assert.NotPanics(func() {
		chain := New()
		final := chain.ThenFunc(handlerOne)
		assert.Implements((*http.Handler)(nil), final)
	})
}
开发者ID:singnurkar,项目名称:apollo,代码行数:8,代码来源:chain_test.go


示例15: TestPaginationRequest

// TestPaginationRequest tests
func TestPaginationRequest(t *testing.T) {
	assert := assert.New(t)

	assert.Implements((*PaginationParameter)(nil), new(PaginationRequest))
	var paging PaginationRequest
	assert.Error(paging.Validate())
	assert.NoError(DefaultPaginationRequest.Validate())
}
开发者ID:gophergala2016,项目名称:source,代码行数:9,代码来源:root_request_test.go


示例16: TestFoundationSession

// TestFoundationSession runs
func TestFoundationSession(t *testing.T) {
	assert := assert.New(t)

	var ctx Context = NewContext(gintest.SharedContext())
	o := ctx.Session()
	assert.NotNil(o)
	assert.Implements((*Session)(nil), o)
}
开发者ID:gophergala2016,项目名称:source,代码行数:9,代码来源:context_test.go


示例17: TestEtcdBackend

func TestEtcdBackend(t *testing.T) {
	s, er := NewEtcdStore([]string{"bad:/url"}, 5*time.Second)
	assert.Error(t, err, "EtcdStore")
	s, er = NewEtcdStore([]string{"http://127.0.0.1:2379"}, 2*time.Second)
	assert.NoError(t, er, "EtcdStore")
	assert.Implements(t, (*Store)(nil), new(EtcdStore), "EtcdStore")
	testImplementation(t, s)
}
开发者ID:timelinelabs,项目名称:pkg,代码行数:8,代码来源:store_integration_test.go


示例18: TestImplementations

func TestImplementations(t *testing.T) {
	es := []interface{}{
		new(DataCenterCapabilities),
		new(Server),
		new(Credentials),
		new(Status),
	}
	for _, e := range es {
		assert.Implements(t, (*Entity)(nil), e)
	}

	ses := []interface{}{
		new(Server),
		new(PublicIPAddress),
	}
	for _, se := range ses {
		assert.Implements(t, (*SavableEntity)(nil), se)
	}
}
开发者ID:rupakg,项目名称:clcgo,代码行数:19,代码来源:server_test.go


示例19: TestFoundationOperation

// TestFoundationOperation runs
func TestFoundationOperation(t *testing.T) {
	assert := assert.New(t)

	var ctx Context = NewContext(gintest.SharedContext())
	o := ctx.Operation()
	assert.NotNil(o)
	assert.Implements((*Operation)(nil), o)
	assert.NotPanics(func() {
		o.Next()
	})
}
开发者ID:gophergala2016,项目名称:source,代码行数:12,代码来源:context_test.go


示例20: TestFoundationRender

// TestFoundationRender runs
func TestFoundationRender(t *testing.T) {
	assert := assert.New(t)

	var ctx Context = NewContext(gintest.SharedContext())
	o := ctx.Render()
	assert.NotNil(o)
	assert.Implements((*Render)(nil), o)
	assert.NotPanics(func() {
		o.JSON(200, map[string]string{"foo": "bar"})
		o.HTML(200, "index", map[string]string{"foo": "bar"})
	})
}
开发者ID:gophergala2016,项目名称:source,代码行数:13,代码来源:context_test.go



注:本文中的github.com/stretchr/testify/assert.Implements函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang assert.InDelta函数代码示例发布时间:2022-05-28
下一篇:
Golang assert.False函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap