Skip to content

Commit

Permalink
Added test
Browse files Browse the repository at this point in the history
Signed-off-by: Helber Belmiro <[email protected]>
  • Loading branch information
hbelmiro committed Jan 3, 2025
1 parent e207026 commit 95287ef
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
6 changes: 3 additions & 3 deletions backend/src/apiserver/client/scheduled_workflow_fake.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ func (c *FakeScheduledWorkflowClient) Get(ctx context.Context, name string, opti
return nil, k8errors.NewNotFound(k8schema.ParseGroupResource("scheduledworkflows.kubeflow.org"), name)
}

func (c *FakeScheduledWorkflowClient) Update(context.Context, *v1beta1.ScheduledWorkflow) (*v1beta1.ScheduledWorkflow, error) {
glog.Error("This fake method is not yet implemented.")
return nil, nil
func (c *FakeScheduledWorkflowClient) Update(_ context.Context, scheduledWorkflow *v1beta1.ScheduledWorkflow) (*v1beta1.ScheduledWorkflow, error) {
c.scheduledWorkflows[scheduledWorkflow.Name] = scheduledWorkflow
return scheduledWorkflow, nil
}

func (c *FakeScheduledWorkflowClient) DeleteCollection(ctx context.Context, options *v1.DeleteOptions, listOptions v1.ListOptions) error {
Expand Down
29 changes: 29 additions & 0 deletions backend/src/apiserver/resource/resource_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3146,6 +3146,35 @@ func TestReportScheduledWorkflowResource_Success_withRuntimeParamsV2(t *testing.
assert.Equal(t, expectedJob.ToV1(), actualJob.ToV1())
}

func TestReconcileSwfCrs(t *testing.T) {
store, manager, job := initWithJobV2(t)
defer store.Close()

fetchedJob, err := manager.GetJob(job.UUID)
require.Nil(t, err)
require.NotNil(t, fetchedJob)

swfClient := store.SwfClient().ScheduledWorkflow("ns1")

options := v1.GetOptions{}
ctx := context.Background()

swf, err := swfClient.Get(ctx, "job-", options)
require.Nil(t, err)

// emulates an invalid/outdated spec
swf.Spec.Workflow.Spec = nil
swf, err = swfClient.Update(ctx, swf)
require.Nil(t, swf.Spec.Workflow.Spec)

err = manager.ReconcileSwfCrs(ctx)
require.Nil(t, err)

swf, err = swfClient.Get(ctx, "job-", options)
require.Nil(t, err)
require.NotNil(t, swf.Spec.Workflow.Spec)
}

func TestReportScheduledWorkflowResource_Error(t *testing.T) {
store := NewFakeClientManagerOrFatal(util.NewFakeTimeForEpoch())
defer store.Close()
Expand Down

0 comments on commit 95287ef

Please sign in to comment.