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


Golang Stub.Calls方法代码示例

本文整理汇总了Golang中github.com/juju/testing.Stub.Calls方法的典型用法代码示例。如果您正苦于以下问题:Golang Stub.Calls方法的具体用法?Golang Stub.Calls怎么用?Golang Stub.Calls使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/juju/testing.Stub的用法示例。


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

示例1: stubCallNames

func stubCallNames(stub *jujutesting.Stub) []string {
	var out []string
	for _, call := range stub.Calls() {
		out = append(out, call.FuncName)
	}
	return out
}
开发者ID:bac,项目名称:juju,代码行数:7,代码来源:worker_test.go

示例2: checkRemovalsMatch

func checkRemovalsMatch(c *gc.C, stub *testing.Stub, expected ...string) {
	var completedRemovals []string
	for _, call := range stub.Calls() {
		if call.FuncName == "CompleteRemoval" {
			machineId := call.Args[0].(names.MachineTag).Id()
			completedRemovals = append(completedRemovals, machineId)
		}
	}
	c.Check(completedRemovals, gc.DeepEquals, expected)
}
开发者ID:bac,项目名称:juju,代码行数:10,代码来源:undertaker_test.go

示例3: checkCalls

func checkCalls(c *gc.C, stub *testing.Stub, names ...string) {
	stub.CheckCallNames(c, names...)
	for _, call := range stub.Calls() {
		c.Check(call.Args, jc.DeepEquals, []interface{}{
			params.Entities{
				[]params.Entity{{"model-some-uuid"}},
			},
		})
	}
}
开发者ID:bac,项目名称:juju,代码行数:10,代码来源:facade_test.go

示例4: CheckMethodCalls

// CheckMethodCalls works like testing.Stub.CheckCalls, but also
// checks the receivers.
func CheckMethodCalls(c *gc.C, stub *testing.Stub, calls ...StubMethodCall) {
	receivers := make([]interface{}, len(calls))
	for i, call := range calls {
		receivers[i] = call.Receiver
	}
	stub.CheckReceivers(c, receivers...)
	c.Check(stub.Calls(), gc.HasLen, len(calls))
	for i, call := range calls {
		stub.CheckCall(c, i, call.FuncName, call.Args...)
	}
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:13,代码来源:stub_network.go

示例5: assertChangePasswordSuccess

func (*ScaryConnectSuite) assertChangePasswordSuccess(c *gc.C, stub *testing.Stub) {
	err := checkChangePassword(c, stub)
	c.Check(err, gc.Equals, apicaller.ErrChangedPassword)
	stub.CheckCallNames(c,
		"Life", "ChangeConfig",
		// Be careful, these are two different SetPassword receivers.
		"SetPassword", "SetOldPassword", "SetPassword",
		"Close",
	)
	checkSaneChange(c, stub.Calls()[2:5])
}
开发者ID:bac,项目名称:juju,代码行数:11,代码来源:connect_test.go

示例6: TestWatch

func (s *ClientSuite) TestWatch(c *gc.C) {
	var stub jujutesting.Stub
	apiCaller := apitesting.APICallerFunc(func(objType string, version int, id, request string, arg, result interface{}) error {
		stub.AddCall(objType+"."+request, id, arg)
		switch request {
		case "Watch":
			*(result.(*params.NotifyWatchResult)) = params.NotifyWatchResult{
				NotifyWatcherId: "abc",
			}
		case "Next":
			// The full success case is tested in api/watcher.
			return errors.New("boom")
		case "Stop":
		}
		return nil
	})

	client := migrationminion.NewClient(apiCaller)
	w, err := client.Watch()
	c.Assert(err, jc.ErrorIsNil)
	defer worker.Stop(w)

	errC := make(chan error)
	go func() {
		errC <- w.Wait()
	}()

	select {
	case err := <-errC:
		c.Assert(err, gc.ErrorMatches, "boom")
		expectedCalls := []jujutesting.StubCall{
			{"Migrationminion.Watch", []interface{}{"", nil}},
			{"MigrationStatusWatcher.Next", []interface{}{"abc", nil}},
			{"MigrationStatusWatcher.Stop", []interface{}{"abc", nil}},
		}
		// The Stop API call happens in a separate goroutine which
		// might execute after the worker has exited so wait for the
		// expected calls to arrive.
		for a := coretesting.LongAttempt.Start(); a.Next(); {
			if len(stub.Calls()) >= len(expectedCalls) {
				return
			}
		}
		stub.CheckCalls(c, expectedCalls)
	case <-time.After(coretesting.LongWait):
		c.Fatal("timed out waiting for watcher to die")
	}
}
开发者ID:bac,项目名称:juju,代码行数:48,代码来源:client_test.go

示例7: checkCalls

func checkCalls(c *gc.C, stub *testing.Stub, names ...string) {
	stub.CheckCallNames(c, names...)
	for _, call := range stub.Calls() {
		c.Check(call.Args, gc.DeepEquals, []interface{}{testEntity})
	}
}
开发者ID:bac,项目名称:juju,代码行数:6,代码来源:worker_test.go


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