当前位置: 首页>>代码示例>>Golang>>正文


Golang assert.NotEqual函数代码示例

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


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

示例1: TestRemotePrecedence

func TestRemotePrecedence(t *testing.T) {
	initJSON()

	remote := bytes.NewReader(remoteExample)
	assert.Equal(t, "0001", Get("id"))
	marshalReader(remote, v.kvstore)
	assert.Equal(t, "0001", Get("id"))
	assert.NotEqual(t, "cronut", Get("type"))
	assert.Equal(t, "remote", Get("newkey"))
	Set("newkey", "newvalue")
	assert.NotEqual(t, "remote", Get("newkey"))
	assert.Equal(t, "newvalue", Get("newkey"))
	Set("newkey", "remote")
}
开发者ID:sara62,项目名称:centrifugo,代码行数:14,代码来源:viper_test.go

示例2: TestClientUpdatePresence

func TestClientUpdatePresence(t *testing.T) {
	app := testApp()
	c, err := newClient(app, &testSession{})
	assert.Equal(t, nil, err)

	timestamp := strconv.FormatInt(time.Now().Unix(), 10)
	cmds := []clientCommand{testConnectCmd(timestamp), testSubscribeCmd("test1"), testSubscribeCmd("test2")}
	err = c.handleCommands(cmds)
	assert.Equal(t, nil, err)
	assert.Equal(t, 2, len(c.channels()))

	assert.NotEqual(t, nil, c.presenceTimer)
	timer := c.presenceTimer
	c.updatePresence()
	assert.NotEqual(t, timer, c.presenceTimer)
}
开发者ID:axmadjon,项目名称:centrifugo,代码行数:16,代码来源:client_test.go

示例3: TestClientMessage

func TestClientMessage(t *testing.T) {
	app := testApp()
	c, err := newClient(app, &testSession{})
	assert.Equal(t, nil, err)

	// empty message
	err = c.message([]byte{})
	assert.Equal(t, ErrInvalidMessage, err)

	// malformed message
	err = c.message([]byte("wroooong"))
	assert.NotEqual(t, nil, err)

	var cmds []clientCommand

	nonConnectFirstCmd := clientCommand{
		Method: "subscribe",
		Params: []byte("{}"),
	}

	cmds = append(cmds, nonConnectFirstCmd)
	cmdBytes, err := json.Marshal(cmds)
	assert.Equal(t, nil, err)
	err = c.message(cmdBytes)
	assert.Equal(t, ErrUnauthorized, err)
}
开发者ID:rvaughan,项目名称:centrifugo,代码行数:26,代码来源:client_test.go

示例4: TestAdminClient

func TestAdminClient(t *testing.T) {
	c, err := newTestAdminClient()
	go c.writer()
	assert.Equal(t, nil, err)
	assert.NotEqual(t, c.uid(), "")
	err = c.send([]byte("message"))
	assert.Equal(t, nil, err)
}
开发者ID:sara62,项目名称:centrifugo,代码行数:8,代码来源:admin_test.go

示例5: TestMemoryEngine

func TestMemoryEngine(t *testing.T) {
	e := testMemoryEngine()
	assert.NotEqual(t, nil, e.historyHub)
	assert.NotEqual(t, nil, e.presenceHub)
	assert.NotEqual(t, e.name(), "")
	assert.Equal(t, nil, e.publish(ChannelID("channel"), []byte("{}")))
	assert.Equal(t, nil, e.subscribe(ChannelID("channel")))
	assert.Equal(t, nil, e.unsubscribe(ChannelID("channel")))
	assert.Equal(t, nil, e.addPresence(ChannelID("channel"), "uid", ClientInfo{}))
	p, err := e.presence(ChannelID("channel"))
	assert.Equal(t, nil, err)
	assert.Equal(t, 1, len(p))
	assert.Equal(t, nil, e.addHistory(ChannelID("channel"), Message{}, 1, 1))
	h, err := e.history(ChannelID("channel"))
	assert.Equal(t, nil, err)
	assert.Equal(t, 1, len(h))
}
开发者ID:rvaughan,项目名称:centrifugo,代码行数:17,代码来源:enginememory_test.go

示例6: TestLevels

func TestLevels(t *testing.T) {
	SetStdoutThreshold(LevelError)
	assert.Equal(t, outputThreshold, LevelError)
	SetLogThreshold(LevelCritical)
	assert.Equal(t, logThreshold, LevelCritical)
	assert.NotEqual(t, outputThreshold, LevelCritical)
	SetStdoutThreshold(LevelWarn)
	assert.Equal(t, outputThreshold, LevelWarn)
}
开发者ID:sara62,项目名称:centrifugo,代码行数:9,代码来源:logger_test.go

示例7: TestClientConnect

func TestClientConnect(t *testing.T) {
	app := testApp()
	c, err := newClient(app, &testSession{})
	assert.Equal(t, nil, err)

	var cmd clientCommand
	var cmds []clientCommand

	cmd = clientCommand{
		Method: "connect",
		Params: []byte(`{"project": "test1"}`),
	}
	cmds = []clientCommand{cmd}
	err = c.handleCommands(cmds)
	assert.Equal(t, ErrInvalidToken, err)

	timestamp := strconv.FormatInt(time.Now().Unix(), 10)
	cmds = []clientCommand{testConnectCmd(timestamp)}
	err = c.handleCommands(cmds)
	assert.Equal(t, nil, err)
	assert.Equal(t, true, c.authenticated)
	ts, err := strconv.Atoi(timestamp)
	assert.Equal(t, int64(ts), c.timestamp)

	clientInfo := c.info(Channel(""))
	assert.Equal(t, UserID("user1"), clientInfo.User)

	assert.Equal(t, 1, len(app.clients.conns))

	assert.NotEqual(t, "", c.uid(), "uid must be already set")
	assert.NotEqual(t, "", c.user(), "user must be already set")

	err = c.clean()
	assert.Equal(t, nil, err)

	assert.Equal(t, 0, len(app.clients.conns))
}
开发者ID:axmadjon,项目名称:centrifugo,代码行数:37,代码来源:client_test.go

示例8: TestAdminClientMessageHandling

func TestAdminClientMessageHandling(t *testing.T) {
	c, err := newTestAdminClient()
	assert.Equal(t, nil, err)
	emptyMsg := ""
	_, err = c.handleMessage([]byte(emptyMsg))
	assert.NotEqual(t, nil, err)
	malformedMsg := "ooops"
	_, err = c.handleMessage([]byte(malformedMsg))
	assert.NotEqual(t, nil, err)
	unknownMsg := "{\"method\":\"unknown\", \"params\": {}}"
	_, err = c.handleMessage([]byte(unknownMsg))
	assert.Equal(t, ErrInvalidMessage, err)
	emptyAuthMethod := "{\"method\":\"auth\", \"params\": {}}"
	_, err = c.handleMessage([]byte(emptyAuthMethod))
	assert.Equal(t, ErrUnauthorized, err)
	s := securecookie.New([]byte(c.app.config.WebSecret), nil)
	token, _ := s.Encode(AuthTokenKey, AuthTokenValue)
	correctAuthMethod := "{\"method\":\"auth\", \"params\": {\"token\":\"" + token + "\"}}"
	_, err = c.handleMessage([]byte(correctAuthMethod))
	assert.Equal(t, nil, err)
	pingCommand := "{\"method\":\"ping\", \"params\": {}}"
	_, err = c.handleMessage([]byte(pingCommand))
	assert.Equal(t, nil, err)
}
开发者ID:sara62,项目名称:centrifugo,代码行数:24,代码来源:admin_test.go

示例9: TestRawWsHandler

func TestRawWsHandler(t *testing.T) {
	app := testApp()
	mux := DefaultMux(app, DefaultMuxOptions)
	server := httptest.NewServer(mux)
	defer server.Close()
	url := "ws" + server.URL[4:]
	conn, resp, err := websocket.DefaultDialer.Dial(url+"/connection/websocket", nil)
	conn.Close()
	assert.Equal(t, nil, err)
	assert.NotEqual(t, nil, conn)
	assert.Equal(t, http.StatusSwitchingProtocols, resp.StatusCode)

	app.Shutdown()
	_, resp, err = websocket.DefaultDialer.Dial(url+"/connection/websocket", nil)
	assert.Equal(t, http.StatusServiceUnavailable, resp.StatusCode)
}
开发者ID:axmadjon,项目名称:centrifugo,代码行数:16,代码来源:handlers_test.go

示例10: TestUnauthenticatedClient

func TestUnauthenticatedClient(t *testing.T) {
	app := testApp()
	c, err := newClient(app, &testSession{})
	assert.Equal(t, nil, err)
	assert.NotEqual(t, "", c.uid())

	// user not set before connect command success
	assert.Equal(t, UserID(""), c.user())

	assert.Equal(t, false, c.authenticated)
	assert.Equal(t, []Channel{}, c.channels())

	// check that unauthenticated client can be cleaned correctly
	err = c.clean()
	assert.Equal(t, nil, err)
}
开发者ID:axmadjon,项目名称:centrifugo,代码行数:16,代码来源:client_test.go

示例11: TestAdminWebsocketHandler

func TestAdminWebsocketHandler(t *testing.T) {
	app := testApp()
	mux := DefaultMux(app, "", "path/to/web", "sockjs url")
	server := httptest.NewServer(mux)
	defer server.Close()
	url := "ws" + server.URL[4:]
	conn, resp, err := websocket.DefaultDialer.Dial(url+"/socket", nil)
	data := map[string]interface{}{
		"method": "ping",
		"params": map[string]string{},
	}
	conn.WriteJSON(data)
	var response interface{}
	conn.ReadJSON(&response)
	conn.Close()
	assert.Equal(t, nil, err)
	assert.NotEqual(t, nil, conn)
	assert.Equal(t, http.StatusSwitchingProtocols, resp.StatusCode)
}
开发者ID:postfix,项目名称:centrifugo,代码行数:19,代码来源:handlers_test.go

示例12: TestAdminWebsocketHandler

func TestAdminWebsocketHandler(t *testing.T) {
	app := testApp()
	app.config.Web = true // admin websocket available only if web enabled at moment
	opts := DefaultMuxOptions
	opts.Web = true
	mux := DefaultMux(app, opts)
	server := httptest.NewServer(mux)
	defer server.Close()
	url := "ws" + server.URL[4:]
	conn, resp, err := websocket.DefaultDialer.Dial(url+"/socket", nil)
	data := map[string]interface{}{
		"method": "ping",
		"params": map[string]string{},
	}
	conn.WriteJSON(data)
	var response interface{}
	conn.ReadJSON(&response)
	conn.Close()
	assert.Equal(t, nil, err)
	assert.NotEqual(t, nil, conn)
	assert.Equal(t, http.StatusSwitchingProtocols, resp.StatusCode)

}
开发者ID:axmadjon,项目名称:centrifugo,代码行数:23,代码来源:handlers_test.go

示例13: TestMemoryEngine

func TestMemoryEngine(t *testing.T) {
	e := testMemoryEngine()
	err := e.run()
	assert.Equal(t, nil, err)
	assert.NotEqual(t, nil, e.historyHub)
	assert.NotEqual(t, nil, e.presenceHub)
	assert.NotEqual(t, e.name(), "")

	err = e.publish(ChannelID("channel"), []byte("{}"), nil)
	assert.Equal(t, nil, err)

	assert.Equal(t, nil, e.subscribe(ChannelID("channel")))

	// Memory engine is actually tightly coupled to application hubs in implementation
	// so calling subscribe on the engine alone is actually a no-op since Application already
	// knows about the subscription.
	// In order to test publish works after subscription is added, we actually need to inject a
	// fake subscription into the Application hub
	fakeConn := &TestConn{"test", "test", []Channel{"channel"}}
	e.app.clients.addSub(ChannelID("channel"), fakeConn)

	// Now we've subscribed...
	err = e.publish(ChannelID("channel"), []byte("{}"), nil)
	assert.Equal(t, nil, err)

	assert.Equal(t, nil, e.unsubscribe(ChannelID("channel")))

	// Same dance to manually remove sub from app hub
	e.app.clients.removeSub(ChannelID("channel"), fakeConn)

	assert.Equal(t, nil, e.addPresence(ChannelID("channel"), "uid", ClientInfo{}))
	p, err := e.presence(ChannelID("channel"))
	assert.Equal(t, nil, err)
	assert.Equal(t, 1, len(p))
	err = e.removePresence(ChannelID("channel"), "uid")
	assert.Equal(t, nil, err)

	msg := Message{UID: MessageID("test UID")}
	msgJSON, _ := json.Marshal(msg)

	// test adding history
	assert.Equal(t, nil, e.publish(ChannelID("channel"), msgJSON, &publishOpts{msg, 4, 1, false}))
	h, err := e.history(ChannelID("channel"), historyOpts{})
	assert.Equal(t, nil, err)
	assert.Equal(t, 1, len(h))
	assert.Equal(t, h[0].UID, MessageID("test UID"))

	// test history limit
	assert.Equal(t, nil, e.publish(ChannelID("channel"), msgJSON, &publishOpts{msg, 4, 1, false}))
	assert.Equal(t, nil, e.publish(ChannelID("channel"), msgJSON, &publishOpts{msg, 4, 1, false}))
	assert.Equal(t, nil, e.publish(ChannelID("channel"), msgJSON, &publishOpts{msg, 4, 1, false}))
	h, err = e.history(ChannelID("channel"), historyOpts{Limit: 2})
	assert.Equal(t, nil, err)
	assert.Equal(t, 2, len(h))

	// test history limit greater than history size
	assert.Equal(t, nil, e.publish(ChannelID("channel"), msgJSON, &publishOpts{msg, 1, 1, false}))
	assert.Equal(t, nil, e.publish(ChannelID("channel"), msgJSON, &publishOpts{msg, 1, 1, false}))
	assert.Equal(t, nil, e.publish(ChannelID("channel"), msgJSON, &publishOpts{msg, 1, 1, false}))
	h, err = e.history(ChannelID("channel"), historyOpts{Limit: 2})

	// HistoryDropInactive tests - new channel to avoid conflicts with test above
	// 1. add history with DropInactive = true should be a no-op if history is empty
	assert.Equal(t, nil, e.publish(ChannelID("channel-2"), msgJSON, &publishOpts{msg, 2, 5, true}))
	h, err = e.history(ChannelID("channel-2"), historyOpts{})
	assert.Equal(t, nil, err)
	assert.Equal(t, 0, len(h))

	// 2. add history with DropInactive = false should always work
	assert.Equal(t, nil, e.publish(ChannelID("channel-2"), msgJSON, &publishOpts{msg, 2, 5, false}))
	h, err = e.history(ChannelID("channel-2"), historyOpts{})
	assert.Equal(t, nil, err)
	assert.Equal(t, 1, len(h))

	// 3. add with DropInactive = true should work immediately since there should be something in history
	// for 5 seconds from above
	assert.Equal(t, nil, e.publish(ChannelID("channel-2"), msgJSON, &publishOpts{msg, 2, 5, true}))
	h, err = e.history(ChannelID("channel-2"), historyOpts{})
	assert.Equal(t, nil, err)
	assert.Equal(t, 2, len(h))
}
开发者ID:sara62,项目名称:centrifugo,代码行数:81,代码来源:enginememory_test.go

示例14: TestSetLogFile

func TestSetLogFile(t *testing.T) {
	err := SetLogFile("/tmp/testing")
	assert.Equal(t, nil, err)
	err = SetLogFile("/i_want_it_to_not_exist_so_error_return/testing")
	assert.NotEqual(t, nil, err)
}
开发者ID:sara62,项目名称:centrifugo,代码行数:6,代码来源:logger_test.go

示例15: TestMediator

func TestMediator(t *testing.T) {
	app := testApp()
	m := &testMediator{}
	app.SetMediator(m)
	assert.NotEqual(t, nil, app.mediator)
}
开发者ID:johnkewforks,项目名称:centrifugo,代码行数:6,代码来源:mediator_test.go


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