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

Golang gomock.InOrder函数代码示例

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

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



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

示例1: TestMODE

// Test the handler for MODE messages
func TestMODE(t *testing.T) {
	c, s := setUp(t)
	defer s.tearDown()

	// Channel modes
	gomock.InOrder(
		s.st.EXPECT().GetChannel("#test1").Return(&state.Channel{Name: "#test1"}),
		s.st.EXPECT().ChannelModes("#test1", "+sk", "somekey"),
	)
	c.h_MODE(ParseLine(":[email protected] MODE #test1 +sk somekey"))

	// Nick modes for Me.
	gomock.InOrder(
		s.st.EXPECT().GetChannel("test").Return(nil),
		s.st.EXPECT().GetNick("test").Return(c.cfg.Me),
		s.st.EXPECT().Me().Return(c.cfg.Me),
		s.st.EXPECT().NickModes("test", "+i"),
	)
	c.h_MODE(ParseLine(":[email protected] MODE test +i"))

	// Check error paths
	gomock.InOrder(
		// send a valid user mode that's not us
		s.st.EXPECT().GetChannel("user1").Return(nil),
		s.st.EXPECT().GetNick("user1").Return(&state.Nick{Nick: "user1"}),
		s.st.EXPECT().Me().Return(c.cfg.Me),
		// Send a random mode for an unknown channel
		s.st.EXPECT().GetChannel("#test2").Return(nil),
		s.st.EXPECT().GetNick("#test2").Return(nil),
	)
	c.h_MODE(ParseLine(":[email protected] MODE user1 +w"))
	c.h_MODE(ParseLine(":[email protected] MODE #test2 +is"))
}
开发者ID:StalkR,项目名称:goirc,代码行数:34,代码来源:handlers_test.go


示例2: Test352

// Test the handler for 352 / RPL_WHOREPLY
func Test352(t *testing.T) {
	c, s := setUp(t)
	defer s.tearDown()

	// Ensure 352 reply calls NickInfo and NickModes
	gomock.InOrder(
		s.st.EXPECT().GetNick("user1").Return(&state.Nick{Nick: "user1"}),
		s.st.EXPECT().Me().Return(c.cfg.Me),
		s.st.EXPECT().NickInfo("user1", "ident1", "host1.com", "name"),
	)
	c.h_352(ParseLine(":irc.server.org 352 test #test1 ident1 host1.com irc.server.org user1 G :0 name"))

	// Check that modes are set correctly from WHOREPLY
	gomock.InOrder(
		s.st.EXPECT().GetNick("user1").Return(&state.Nick{Nick: "user1"}),
		s.st.EXPECT().Me().Return(c.cfg.Me),
		s.st.EXPECT().NickInfo("user1", "ident1", "host1.com", "name"),
		s.st.EXPECT().NickModes("user1", "+o"),
		s.st.EXPECT().NickModes("user1", "+i"),
	)
	c.h_352(ParseLine(":irc.server.org 352 test #test1 ident1 host1.com irc.server.org user1 H* :0 name"))

	// Check error paths -- send a 352 for an unknown nick
	s.st.EXPECT().GetNick("user2").Return(nil)
	c.h_352(ParseLine(":irc.server.org 352 test #test2 ident2 host2.com irc.server.org user2 G :0 fooo"))
}
开发者ID:StalkR,项目名称:goirc,代码行数:27,代码来源:handlers_test.go


示例3: TestJOIN

// Test the handler for JOIN messages
func TestJOIN(t *testing.T) {
	c, s := setUp(t)
	defer s.tearDown()

	// The state tracker should be creating a new channel in this first test
	chan1 := state.NewChannel("#test1")

	gomock.InOrder(
		s.st.EXPECT().GetChannel("#test1").Return(nil),
		s.st.EXPECT().GetNick("test").Return(c.Me),
		s.st.EXPECT().NewChannel("#test1").Return(chan1),
		s.st.EXPECT().Associate(chan1, c.Me),
	)

	// Use #test1 to test expected behaviour
	// Call handler with JOIN by test to #test1
	c.h_JOIN(parseLine(":[email protected] JOIN :#test1"))

	// Verify that the MODE and WHO commands are sent correctly
	s.nc.Expect("MODE #test1")
	s.nc.Expect("WHO #test1")

	// In this second test, we should be creating a new nick
	nick1 := state.NewNick("user1")

	gomock.InOrder(
		s.st.EXPECT().GetChannel("#test1").Return(chan1),
		s.st.EXPECT().GetNick("user1").Return(nil),
		s.st.EXPECT().NewNick("user1").Return(nick1),
		s.st.EXPECT().Associate(chan1, nick1),
	)

	// OK, now #test1 exists, JOIN another user we don't know about
	c.h_JOIN(parseLine(":[email protected] JOIN :#test1"))

	// Verify that the WHO command is sent correctly
	s.nc.Expect("WHO user1")

	// In this third test, we'll be pretending we know about the nick already.
	nick2 := state.NewNick("user2")
	gomock.InOrder(
		s.st.EXPECT().GetChannel("#test1").Return(chan1),
		s.st.EXPECT().GetNick("user2").Return(nick2),
		s.st.EXPECT().Associate(chan1, nick2),
	)
	c.h_JOIN(parseLine(":[email protected] JOIN :#test1"))

	// Test error paths
	gomock.InOrder(
		// unknown channel, unknown nick
		s.st.EXPECT().GetChannel("#test2").Return(nil),
		s.st.EXPECT().GetNick("blah").Return(nil),
		// unknown channel, known nick that isn't Me.
		s.st.EXPECT().GetChannel("#test2").Return(nil),
		s.st.EXPECT().GetNick("user2").Return(nick2),
	)
	c.h_JOIN(parseLine(":[email protected] JOIN :#test2"))
	c.h_JOIN(parseLine(":[email protected] JOIN :#test2"))
}
开发者ID:Jyggafey,项目名称:drone,代码行数:60,代码来源:handlers_test.go


示例4: Test353

// Test the handler for 353 / RPL_NAMREPLY
func Test353(t *testing.T) {
	c, s := setUp(t)
	defer s.tearDown()

	// Create #test1, whose user list we're mostly unfamiliar with
	chan1 := state.NewChannel("#test1")

	// Create maps for testing -- this is what the mock ST calls will return
	nicks := make(map[string]*state.Nick)
	privs := make(map[string]*state.ChanPrivs)

	nicks["test"] = c.Me
	privs["test"] = new(state.ChanPrivs)

	for _, n := range []string{"user1", "user2", "voice", "halfop",
		"op", "admin", "owner"} {
		nicks[n] = state.NewNick(n)
		privs[n] = new(state.ChanPrivs)
	}

	// 353 handler is called twice, so GetChannel will be called twice
	s.st.EXPECT().GetChannel("#test1").Return(chan1).Times(2)
	gomock.InOrder(
		// "test" is Me, i am known, and already on the channel
		s.st.EXPECT().GetNick("test").Return(c.Me),
		s.st.EXPECT().IsOn("#test1", "test").Return(privs["test"], true),
		// user1 is known, but not on the channel, so should be associated
		s.st.EXPECT().GetNick("user1").Return(nicks["user1"]),
		s.st.EXPECT().IsOn("#test1", "user1").Return(nil, false),
		s.st.EXPECT().Associate(chan1, nicks["user1"]).Return(privs["user1"]),
	)
	for _, n := range []string{"user2", "voice", "halfop", "op", "admin", "owner"} {
		gomock.InOrder(
			s.st.EXPECT().GetNick(n).Return(nil),
			s.st.EXPECT().NewNick(n).Return(nicks[n]),
			s.st.EXPECT().IsOn("#test1", n).Return(nil, false),
			s.st.EXPECT().Associate(chan1, nicks[n]).Return(privs[n]),
		)
	}

	// Send a couple of names replies (complete with trailing space)
	c.h_353(parseLine(":irc.server.org 353 test = #test1 :test @user1 user2 +voice "))
	c.h_353(parseLine(":irc.server.org 353 test = #test1 :%halfop @op &admin ~owner "))

	if p := privs["user2"]; p.Voice || p.HalfOp || p.Op || p.Admin || p.Owner {
		t.Errorf("353 handler incorrectly set modes on nick.")
	}

	if !privs["user1"].Op || !privs["voice"].Voice || !privs["halfop"].HalfOp ||
		!privs["op"].Op || !privs["admin"].Admin || !privs["owner"].Owner {
		t.Errorf("353 handler failed to set correct modes for nicks.")
	}

	// Check error paths -- send 353 for an unknown channel
	s.st.EXPECT().GetChannel("#test2").Return(nil)
	c.h_353(parseLine(":irc.server.org 353 test = #test2 :test ~user3"))
}
开发者ID:Jyggafey,项目名称:drone,代码行数:58,代码来源:handlers_test.go


示例5: TestTOPIC

// Test the handler for TOPIC messages
func TestTOPIC(t *testing.T) {
	c, s := setUp(t)
	defer s.tearDown()

	chan1 := state.NewChannel("#test1", s.log)

	// Assert that it has no topic originally
	if chan1.Topic != "" {
		t.Errorf("Test channel already has a topic.")
	}

	// Send a TOPIC line
	s.st.EXPECT().GetChannel("#test1").Return(chan1)
	c.h_TOPIC(parseLine(":[email protected] TOPIC #test1 :something something"))

	// Make sure the channel's topic has been changed
	if chan1.Topic != "something something" {
		t.Errorf("Topic of test channel not set correctly.")
	}

	// Check error paths -- send a topic for an unknown channel
	gomock.InOrder(
		s.st.EXPECT().GetChannel("#test2").Return(nil),
		s.log.EXPECT().Warn("irc.TOPIC(): topic change on unknown channel %s",
			"#test2"),
	)
	c.h_TOPIC(parseLine(":[email protected] TOPIC #test2 :dark side"))
}
开发者ID:quadr,项目名称:goirc,代码行数:29,代码来源:handlers_test.go


示例6: Test311

// Test the handler for 311 / RPL_WHOISUSER
func Test311(t *testing.T) {
	c, s := setUp(t)
	defer s.tearDown()

	// Create user1, who we know little about
	nick1 := state.NewNick("user1", s.log)

	// Send a 311 reply
	s.st.EXPECT().GetNick("user1").Return(nick1)
	c.h_311(parseLine(":irc.server.org 311 test user1 ident1 host1.com * :name"))

	// Verify we now know more about user1
	if nick1.Ident != "ident1" ||
		nick1.Host != "host1.com" ||
		nick1.Name != "name" {
		t.Errorf("WHOIS info of user1 not set correctly.")
	}

	// Check error paths -- send a 311 for an unknown nick
	gomock.InOrder(
		s.st.EXPECT().GetNick("user2").Return(nil),
		s.log.EXPECT().Warn("irc.311(): received WHOIS info for unknown nick %s",
			"user2"),
	)
	c.h_311(parseLine(":irc.server.org 311 test user2 ident2 host2.com * :dongs"))
}
开发者ID:quadr,项目名称:goirc,代码行数:27,代码来源:handlers_test.go


示例7: Test332

// Test the handler for 332 / RPL_TOPIC
func Test332(t *testing.T) {
	c, s := setUp(t)
	defer s.tearDown()

	// Create #test1, whose topic we don't know
	chan1 := state.NewChannel("#test1", s.log)

	// Assert that it has no topic originally
	if chan1.Topic != "" {
		t.Errorf("Test channel already has a topic.")
	}

	// Send a 332 reply
	s.st.EXPECT().GetChannel("#test1").Return(chan1)
	c.h_332(parseLine(":irc.server.org 332 test #test1 :something something"))

	// Make sure the channel's topic has been changed
	if chan1.Topic != "something something" {
		t.Errorf("Topic of test channel not set correctly.")
	}

	// Check unknown channel causes an error
	gomock.InOrder(
		s.st.EXPECT().GetChannel("#test2").Return(nil),
		s.log.EXPECT().Warn("irc.332(): received TOPIC value for unknown "+
			"channel %s", "#test2"),
	)
	c.h_332(parseLine(":irc.server.org 332 test #test2 :dark side"))
}
开发者ID:quadr,项目名称:goirc,代码行数:30,代码来源:handlers_test.go


示例8: TestStartSupervisedUpgrade

func TestStartSupervisedUpgrade(t *testing.T) {
	mockCtrl := gomock.NewController(t)
	defer mockCtrl.Finish()

	mockDocker := NewMockdockerClient(mockCtrl)
	mockDownloader := NewMockdownloader(mockCtrl)

	gomock.InOrder(
		mockDocker.EXPECT().RemoveExistingAgentContainer(),
		mockDocker.EXPECT().StartAgent().Return(upgradeAgentExitCode, nil),
		mockDownloader.EXPECT().LoadDesiredAgent().Return(&os.File{}, nil),
		mockDocker.EXPECT().LoadImage(gomock.Any()),
		mockDownloader.EXPECT().RecordCachedAgent(),
		mockDocker.EXPECT().RemoveExistingAgentContainer(),
		mockDocker.EXPECT().StartAgent().Return(terminalSuccessAgentExitCode, nil),
	)

	engine := &Engine{
		downloader: mockDownloader,
		docker:     mockDocker,
	}
	err := engine.StartSupervised()
	if err != nil {
		t.Error("Expected error to be nil but was returned")
	}
}
开发者ID:tomwilkie,项目名称:amazon-ecs-init,代码行数:26,代码来源:engine_test.go


示例9: TestStartSupervisedExitsWhenTerminalSuccess

func TestStartSupervisedExitsWhenTerminalSuccess(t *testing.T) {
	mockCtrl := gomock.NewController(t)
	defer mockCtrl.Finish()

	mockDocker := NewMockdockerClient(mockCtrl)

	gomock.InOrder(
		mockDocker.EXPECT().RemoveExistingAgentContainer(),
		mockDocker.EXPECT().StartAgent().Return(1, nil),
		mockDocker.EXPECT().RemoveExistingAgentContainer(),
		mockDocker.EXPECT().StartAgent().Return(1, nil),
		mockDocker.EXPECT().RemoveExistingAgentContainer(),
		mockDocker.EXPECT().StartAgent().Return(1, nil),
		mockDocker.EXPECT().RemoveExistingAgentContainer(),
		mockDocker.EXPECT().StartAgent().Return(terminalSuccessAgentExitCode, nil),
	)

	engine := &Engine{
		docker: mockDocker,
	}
	err := engine.StartSupervised()
	if err != nil {
		t.Error("Expected error to be nil but was returned")
	}
}
开发者ID:tomwilkie,项目名称:amazon-ecs-init,代码行数:25,代码来源:engine_test.go


示例10: TestClientWrongMessageType

// TestCase: Wrong message type has been received in the client.
func TestClientWrongMessageType(t *testing.T) {
	mockCtrl := gomock.NewController(t)
	transport := thrift.NewTMemoryBuffer()
	protocol := NewMockTProtocol(mockCtrl)
	gomock.InOrder(
		protocol.EXPECT().WriteMessageBegin("testString", thrift.CALL, int32(1)),
		protocol.EXPECT().WriteStructBegin("testString_args"),
		protocol.EXPECT().WriteFieldBegin("s", thrift.TType(thrift.STRING), int16(1)),
		protocol.EXPECT().WriteString("test"),
		protocol.EXPECT().WriteFieldEnd(),
		protocol.EXPECT().WriteFieldStop(),
		protocol.EXPECT().WriteStructEnd(),
		protocol.EXPECT().WriteMessageEnd(),
		protocol.EXPECT().Flush(),
		protocol.EXPECT().ReadMessageBegin().Return("testString", thrift.INVALID_TMESSAGE_TYPE, int32(1), nil),
	)

	client := errortest.NewErrorTestClientProtocol(transport, protocol, protocol)
	_, err := client.TestString("test")
	mockCtrl.Finish()
	appErr, ok := err.(thrift.TApplicationException)
	if !ok {
		t.Fatal("Expected TApplicationException")
	}
	if appErr.TypeId() != thrift.INVALID_MESSAGE_TYPE_EXCEPTION {
		t.Fatal("Expected INVALID_MESSAGE_TYPE_EXCEPTION error")
	}
}
开发者ID:qadium,项目名称:thrift,代码行数:29,代码来源:client_error_test.go


示例11: Test671

// Test the handler for 671 (unreal specific)
func Test671(t *testing.T) {
	c, s := setUp(t)
	defer s.tearDown()

	// Create user1, who should not be secure
	nick1 := state.NewNick("user1", s.log)
	if nick1.Modes.SSL {
		t.Errorf("Test nick user1 is already using SSL?")
	}

	// Send a 671 reply
	s.st.EXPECT().GetNick("user1").Return(nick1)
	c.h_671(parseLine(":irc.server.org 671 test user1 :some ignored text"))

	// Ensure user1 is now known to be on an SSL connection
	if !nick1.Modes.SSL {
		t.Errorf("Test nick user1 not using SSL?")
	}

	// Check error paths -- send a 671 for an unknown nick
	gomock.InOrder(
		s.st.EXPECT().GetNick("user2").Return(nil),
		s.log.EXPECT().Warn("irc.671(): received WHOIS SSL info for unknown "+
			"nick %s", "user2"),
	)
	c.h_671(parseLine(":irc.server.org 671 test user2 :some ignored text"))
}
开发者ID:quadr,项目名称:goirc,代码行数:28,代码来源:handlers_test.go


示例12: Test433

// Test the handler for 433 / ERR_NICKNAMEINUSE
func Test433(t *testing.T) {
	c, s := setUp(t)
	defer s.tearDown()

	// Call handler with a 433 line, not triggering c.cfg.Me.Renick()
	s.st.EXPECT().Me().Return(c.cfg.Me)
	c.h_433(ParseLine(":irc.server.org 433 test new :Nickname is already in use."))
	s.nc.Expect("NICK new_")

	// Send a line that will trigger a renick. This happens when our wanted
	// nick is unavailable during initial negotiation, so we must choose a
	// different one before the connection can proceed. No NICK line will be
	// sent by the server to confirm nick change in this case.
	gomock.InOrder(
		s.st.EXPECT().Me().Return(c.cfg.Me),
		s.st.EXPECT().ReNick("test", "test_").Return(c.cfg.Me),
	)
	c.h_433(ParseLine(":irc.server.org 433 test test :Nickname is already in use."))
	s.nc.Expect("NICK test_")

	// Test the code path that *doesn't* involve state tracking.
	c.st = nil
	c.h_433(ParseLine(":irc.server.org 433 test test :Nickname is already in use."))
	s.nc.Expect("NICK test_")

	if c.cfg.Me.Nick != "test_" {
		t.Errorf("My nick not updated from '%s'.", c.cfg.Me.Nick)
	}
	c.st = s.st
}
开发者ID:StalkR,项目名称:goirc,代码行数:31,代码来源:handlers_test.go


示例13: TestClientSeqIdMismatch

// TestCase: Mismatching sequence id has been received in the client.
func TestClientSeqIdMismatch(t *testing.T) {
	mockCtrl := gomock.NewController(t)
	transport := thrift.NewTMemoryBuffer()
	protocol := NewMockTProtocol(mockCtrl)
	gomock.InOrder(
		protocol.EXPECT().WriteMessageBegin("testString", thrift.CALL, int32(1)),
		protocol.EXPECT().WriteStructBegin("testString_args"),
		protocol.EXPECT().WriteFieldBegin("s", thrift.TType(thrift.STRING), int16(1)),
		protocol.EXPECT().WriteString("test"),
		protocol.EXPECT().WriteFieldEnd(),
		protocol.EXPECT().WriteFieldStop(),
		protocol.EXPECT().WriteStructEnd(),
		protocol.EXPECT().WriteMessageEnd(),
		protocol.EXPECT().Flush(),
		protocol.EXPECT().ReadMessageBegin().Return("testString", thrift.REPLY, int32(2), nil),
	)

	client := errortest.NewErrorTestClientProtocol(transport, protocol, protocol)
	_, err := client.TestString("test")
	mockCtrl.Finish()
	appErr, ok := err.(thrift.TApplicationException)
	if !ok {
		t.Fatal("Expected TApplicationException")
	}
	if appErr.TypeId() != thrift.BAD_SEQUENCE_ID {
		t.Fatal("Expected BAD_SEQUENCE_ID error")
	}
}
开发者ID:qadium,项目名称:thrift,代码行数:29,代码来源:client_error_test.go


示例14: Test001

// Test the handler for 001 / RPL_WELCOME
func Test001(t *testing.T) {
	c, s := setUp(t)
	defer s.tearDown()

	l := ParseLine(":irc.server.org 001 test :Welcome to IRC [email protected]")
	// Set up a handler to detect whether connected handler is called from 001
	hcon := false
	c.HandleFunc("connected", func(conn *Conn, line *Line) {
		hcon = true
	})

	// Test state tracking first.
	gomock.InOrder(
		s.st.EXPECT().Me().Return(c.cfg.Me),
		s.st.EXPECT().NickInfo("test", "test", "somehost.com", "Testing IRC"),
	)
	// Call handler with a valid 001 line
	c.h_001(l)
	<-time.After(time.Millisecond)
	if !hcon {
		t.Errorf("001 handler did not dispatch connected event.")
	}

	// Now without state tracking.
	c.st = nil
	c.h_001(l)
	// Check host parsed correctly
	if c.cfg.Me.Host != "somehost.com" {
		t.Errorf("Host parsing failed, host is '%s'.", c.cfg.Me.Host)
	}
	c.st = s.st
}
开发者ID:StalkR,项目名称:goirc,代码行数:33,代码来源:handlers_test.go


示例15: Test353

// Test the handler for 353 / RPL_NAMREPLY
func Test353(t *testing.T) {
	c, s := setUp(t)
	defer s.tearDown()

	// 353 handler is called twice, so GetChannel will be called twice
	s.st.EXPECT().GetChannel("#test1").Return(&state.Channel{Name: "#test1"}).Times(2)
	gomock.InOrder(
		// "test" is Me, i am known, and already on the channel
		s.st.EXPECT().GetNick("test").Return(c.cfg.Me),
		s.st.EXPECT().IsOn("#test1", "test").Return(&state.ChanPrivs{}, true),
		// user1 is known, but not on the channel, so should be associated
		s.st.EXPECT().GetNick("user1").Return(&state.Nick{Nick: "user1"}),
		s.st.EXPECT().IsOn("#test1", "user1").Return(nil, false),
		s.st.EXPECT().Associate("#test1", "user1").Return(&state.ChanPrivs{}),
		s.st.EXPECT().ChannelModes("#test1", "+o", "user1"),
	)
	for n, m := range map[string]string{
		"user2":  "",
		"voice":  "+v",
		"halfop": "+h",
		"op":     "+o",
		"admin":  "+a",
		"owner":  "+q",
	} {
		calls := []*gomock.Call{
			s.st.EXPECT().GetNick(n).Return(nil),
			s.st.EXPECT().NewNick(n).Return(&state.Nick{Nick: n}),
			s.st.EXPECT().IsOn("#test1", n).Return(nil, false),
			s.st.EXPECT().Associate("#test1", n).Return(&state.ChanPrivs{}),
		}
		if m != "" {
			calls = append(calls, s.st.EXPECT().ChannelModes("#test1", m, n))
		}
		gomock.InOrder(calls...)
	}

	// Send a couple of names replies (complete with trailing space)
	c.h_353(ParseLine(":irc.server.org 353 test = #test1 :test @user1 user2 +voice "))
	c.h_353(ParseLine(":irc.server.org 353 test = #test1 :%halfop @op &admin ~owner "))

	// Check error paths -- send 353 for an unknown channel
	s.st.EXPECT().GetChannel("#test2").Return(nil)
	c.h_353(ParseLine(":irc.server.org 353 test = #test2 :test ~user3"))
}
开发者ID:StalkR,项目名称:goirc,代码行数:45,代码来源:handlers_test.go


示例16: TestMODE

// Test the handler for MODE messages
func TestMODE(t *testing.T) {
	c, s := setUp(t)
	defer s.tearDown()

	chan1 := state.NewChannel("#test1", s.log)
	nick1 := state.NewNick("user1", s.log)

	// Send a channel mode line. Inconveniently, Channel and Nick objects
	// aren't mockable with gomock as they're not interface types (and I
	// don't want them to be, writing accessors for struct fields sucks).
	// This makes testing whether ParseModes is called correctly harder.
	s.st.EXPECT().GetChannel("#test1").Return(chan1)
	c.h_MODE(parseLine(":[email protected] MODE #test1 +sk somekey"))
	if !chan1.Modes.Secret || chan1.Modes.Key != "somekey" {
		t.Errorf("Channel.ParseModes() not called correctly.")
	}

	// Send a nick mode line, returning Me
	gomock.InOrder(
		s.st.EXPECT().GetChannel("test").Return(nil),
		s.st.EXPECT().GetNick("test").Return(c.Me),
	)
	c.h_MODE(parseLine(":[email protected] MODE test +i"))
	if !c.Me.Modes.Invisible {
		t.Errorf("Nick.ParseModes() not called correctly.")
	}

	// Check error paths
	gomock.InOrder(
		// send a valid user mode that's not us
		s.st.EXPECT().GetChannel("user1").Return(nil),
		s.st.EXPECT().GetNick("user1").Return(nick1),
		s.log.EXPECT().Warn("irc.MODE(): recieved MODE %s for (non-me) nick %s",
			"+w", "user1"),
		// Send a random mode for an unknown channel
		s.st.EXPECT().GetChannel("#test2").Return(nil),
		s.st.EXPECT().GetNick("#test2").Return(nil),
		s.log.EXPECT().Warn("irc.MODE(): not sure what to do with MODE %s",
			"#test2 +is"),
	)
	c.h_MODE(parseLine(":[email protected] MODE user1 +w"))
	c.h_MODE(parseLine(":[email protected] MODE #test2 +is"))
}
开发者ID:quadr,项目名称:goirc,代码行数:44,代码来源:handlers_test.go


示例17: TestNoOptionalUnsetFieldsOnWire

//Make sure that optional fields are not being serialized
func TestNoOptionalUnsetFieldsOnWire(t *testing.T) {
	mockCtrl := gomock.NewController(t)
	defer mockCtrl.Finish()
	proto := NewMockTProtocol(mockCtrl)
	gomock.InOrder(
		proto.EXPECT().WriteStructBegin("all_optional").Return(nil),
		proto.EXPECT().WriteFieldStop().Return(nil),
		proto.EXPECT().WriteStructEnd().Return(nil),
	)
	ao := optionalfieldstest.NewAllOptional()
	ao.Write(proto)
}
开发者ID:GDGroup,项目名称:thrift,代码行数:13,代码来源:optional_fields_test.go


示例18: commonTestOrderedCalls

func commonTestOrderedCalls(t *testing.T) (reporter *ErrorReporter, ctrl *gomock.Controller, subjectOne, subjectTwo *Subject) {
	reporter, ctrl = createFixtures(t)

	subjectOne = new(Subject)
	subjectTwo = new(Subject)

	gomock.InOrder(
		ctrl.RecordCall(subjectOne, "FooMethod", "1").AnyTimes(),
		ctrl.RecordCall(subjectTwo, "FooMethod", "2"),
		ctrl.RecordCall(subjectTwo, "BarMethod", "3"),
	)

	return
}
开发者ID:Jyggafey,项目名称:drone,代码行数:14,代码来源:controller_test.go


示例19: Test324

// Test the handler for 324 / RPL_CHANNELMODEIS
func Test324(t *testing.T) {
	c, s := setUp(t)
	defer s.tearDown()

	// Ensure 324 reply calls ChannelModes
	gomock.InOrder(
		s.st.EXPECT().GetChannel("#test1").Return(&state.Channel{Name: "#test1"}),
		s.st.EXPECT().ChannelModes("#test1", "+sk", "somekey"),
	)
	c.h_324(ParseLine(":irc.server.org 324 test #test1 +sk somekey"))

	// Check error paths -- send 324 for an unknown channel
	s.st.EXPECT().GetChannel("#test2").Return(nil)
	c.h_324(ParseLine(":irc.server.org 324 test #test2 +pmt"))
}
开发者ID:StalkR,项目名称:goirc,代码行数:16,代码来源:handlers_test.go


示例20: TestTOPIC

// Test the handler for TOPIC messages
func TestTOPIC(t *testing.T) {
	c, s := setUp(t)
	defer s.tearDown()

	// Ensure TOPIC reply calls Topic
	gomock.InOrder(
		s.st.EXPECT().GetChannel("#test1").Return(&state.Channel{Name: "#test1"}),
		s.st.EXPECT().Topic("#test1", "something something"),
	)
	c.h_TOPIC(ParseLine(":[email protected] TOPIC #test1 :something something"))

	// Check error paths -- send a topic for an unknown channel
	s.st.EXPECT().GetChannel("#test2").Return(nil)
	c.h_TOPIC(ParseLine(":[email protected] TOPIC #test2 :dark side"))
}
开发者ID:StalkR,项目名称:goirc,代码行数:16,代码来源:handlers_test.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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