コード例 #1
0
func MockRemoveExpectedCall(m *mock.Mock, methodName string, arguments ...interface{}) bool {
	for i, call := range m.ExpectedCalls {
		if call.Method == methodName {
			_, difference := call.Arguments.Diff(arguments)
			if difference == 0 {
				m.ExpectedCalls = append(m.ExpectedCalls[:i], m.ExpectedCalls[i+1:]...)
				return true
			}
		}
	}
	return false
}
コード例 #2
0
func installPods(controller *Controller, podInterface, podStore *mock.Mock, namespace string, count int) {
	keys := make([]string, count)
	for i := 0; i < count; i++ {
		pod := &api.Pod{
			ObjectMeta: api.ObjectMeta{
				Name:      fmt.Sprintf("pod%02d", i),
				Namespace: namespace,
				UID:       kubetypes.UID(uuid.New()),
				Labels: map[string]string{
					"app": fmt.Sprintf("pod%02d", i),
				},
			},
		}
		key := fmt.Sprintf("%s/%s", namespace, pod.Name)
		keys[i] = key
		podStore.On("GetByKey", key).Return(pod, true, nil)
		podInterface.On("Update", pod).Return(pod, nil)
		podInterface.On("List", makeListOptSelector(pod.Labels)).Return(&api.PodList{Items: []api.Pod{*pod}}, nil)
		controller.AddPod(pod)
	}

	podStore.On("ListKeys").Return(keys)
}