Skip to content

Commit

Permalink
fix: Fix test cases
Browse files Browse the repository at this point in the history
Signed-off-by: Ce Gao <gaoce@caicloud.io>
  • Loading branch information
gaocegege committed May 23, 2019
1 parent 2e9661c commit eb03b0c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 0 additions & 1 deletion pkg/controller/v1alpha2/trial/trial_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@ func (r *ReconcileTrial) reconcileTrial(instance *trialsv1alpha2.Trial) error {
}

func (r *ReconcileTrial) reconcileJob(instance *trialsv1alpha2.Trial, desiredJob *unstructured.Unstructured) (*unstructured.Unstructured, error) {

var err error
logger := log.WithValues("Trial", types.NamespacedName{Name: instance.GetName(), Namespace: instance.GetNamespace()})
apiVersion := desiredJob.GetAPIVersion()
Expand Down
6 changes: 5 additions & 1 deletion pkg/controller/v1alpha2/trial/trial_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func TestReconcileTFJobTrial(t *testing.T) {
Should(gomega.MatchError("tfjobs.kubeflow.org \"test\" not found"))
}

func TestReconcileComplectedTFJobTrial(t *testing.T) {
func TestReconcileCompletedTFJobTrial(t *testing.T) {
g := gomega.NewGomegaWithT(t)
instance := newFakeTrialWithTFJob()

Expand All @@ -174,6 +174,9 @@ func TestReconcileComplectedTFJobTrial(t *testing.T) {
mc := managerclientmock.NewMockManagerClient(mockCtrl)
mc.EXPECT().CreateTrialInDB(gomock.Any()).Return(nil).AnyTimes()
mc.EXPECT().UpdateTrialStatusInDB(gomock.Any()).Return(nil).AnyTimes()
mc.EXPECT().GetTrialObservationLog(gomock.Any()).Return(&api_pb.GetObservationLogReply{
ObservationLog: nil,
}, nil).AnyTimes()

// Setup the Manager and Controller. Wrap the Controller Reconcile function so it writes each request to a
// channel when it is finished.
Expand Down Expand Up @@ -215,6 +218,7 @@ func TestReconcileComplectedTFJobTrial(t *testing.T) {
g.Expect(err).NotTo(gomega.HaveOccurred())
defer c.Delete(context.TODO(), instance)
g.Eventually(requests, timeout).Should(gomega.Receive(gomega.Equal(expectedRequest)))
g.Eventually(requests, timeout).Should(gomega.Receive(gomega.Equal(expectedRequest)))

g.Eventually(func() error {
return c.Get(context.TODO(), expectedRequest.NamespacedName, instance)
Expand Down

0 comments on commit eb03b0c

Please sign in to comment.