Skip to content

Commit

Permalink
Remove test for now
Browse files Browse the repository at this point in the history
Signed-off-by: terrytangyuan <[email protected]>
  • Loading branch information
terrytangyuan committed Apr 6, 2021
1 parent 629da0e commit 5f7fb29
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 52 deletions.
10 changes: 5 additions & 5 deletions workflow/executor/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ func (we *WorkflowExecutor) ExecResource(action string, manifestPath string, fla
if err != nil {
return "", "", "", err
}
group := obj.GroupVersionKind().Group
resourceGroup := obj.GroupVersionKind().Group
resourceName := obj.GetName()
if group == "" || resourceName == "" {
return "", "", "", errors.New(errors.CodeBadRequest, "Both group and name are required but at least one of them is missing from the manifest")
resourceKind := obj.GroupVersionKind().Kind
if resourceGroup == "" || resourceName == "" || resourceKind == "" {
return "", "", "", errors.New(errors.CodeBadRequest, "Group, kind, and name are all required but at least one of them is missing from the manifest")
}

resourceFullName := fmt.Sprintf("%s.%s/%s", obj.GroupVersionKind().Kind, group, resourceName)
resourceFullName := fmt.Sprintf("%s.%s/%s", resourceKind, resourceGroup, resourceName)
selfLink := obj.GetSelfLink()
log.Infof("Resource: %s/%s. SelfLink: %s", obj.GetNamespace(), resourceFullName, selfLink)
return obj.GetNamespace(), resourceFullName, selfLink, nil
Expand Down
47 changes: 0 additions & 47 deletions workflow/executor/resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,50 +116,3 @@ func TestResourceConditionsMatching(t *testing.T) {
assert.Error(t, err, "Neither success condition nor the failure condition has been matched. Retrying...")
assert.True(t, finished)
}

// TestExecResource tests whether Resource is executed properly.
func TestExecResource(t *testing.T) {
mockRuntimeExecutor := mocks.ContainerRuntimeExecutor{}
template := wfv1.Template{
Resource: &wfv1.ResourceTemplate{
Action: "fake",
Flags: []string{"--fake=true"},
},
}
we := WorkflowExecutor{
PodName: fakePodName,
Template: template,
ClientSet: fake.NewSimpleClientset(),
Namespace: fakeNamespace,
PodAnnotationsPath: fakeAnnotations,
ExecutionControl: nil,
RuntimeExecutor: &mockRuntimeExecutor,
}

manifestWithoutGroup, err := ioutil.TempFile("/tmp", "manifest-without-group")
assert.NoError(t, err)
_, err = manifestWithoutGroup.WriteString(`apiVersion: ""
kind: Pod`)
assert.NoError(t, err)
defer func() { _ = os.Remove(manifestWithoutGroup.Name()) }()
_, _, _, err = we.ExecResource("get", manifestWithoutGroup.Name(), nil)
assert.EqualError(t, err, "Both group and name are required but at least one of them is missing from the manifest")

manifestWithoutResName, err := ioutil.TempFile("/tmp", "manifest-without-resource-name")
assert.NoError(t, err)
_, err = manifestWithoutResName.WriteString(`apiVersion: v1
kind: Pod`)
assert.NoError(t, err)
defer func() { _ = os.Remove(manifestWithoutResName.Name()) }()
_, _, _, err = we.ExecResource("get", manifestWithoutResName.Name(), nil)
assert.EqualError(t, err, "Both group and name are required but at least one of them is missing from the manifest")

manifestWithoutKind, err := ioutil.TempFile("/tmp", "manifest-without-resource-kind")
assert.NoError(t, err)
_, err = manifestWithoutKind.WriteString(`apiVersion: v1`)
assert.NoError(t, err)
defer func() { _ = os.Remove(manifestWithoutKind.Name()) }()
_, _, _, err = we.ExecResource("get", manifestWithoutKind.Name(), nil)
assert.NotNil(t, err)
assert.Regexp(t, "error: unable to decode.*: Object 'Kind' is missing in.*", err.Error())
}

0 comments on commit 5f7fb29

Please sign in to comment.