Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add new component types to test utils #496

Merged
merged 1 commit into from
Jun 15, 2021

Conversation

kim-tsao
Copy link
Contributor

What does this PR do?

Adds the kubernetes and openshift component types to the test utils for improved coverage. Corresponding changes in library repo will be added once this PR has been approved and merged.

What issues does this PR fix or reference?

#495

Is your PR tested? Consider putting some instruction how to test your changes

Yes, I manually ran the go test -v commands locally against the api and library repos to ensure there were no regressions

Docs PR

N/A

@openshift-ci
Copy link

openshift-ci bot commented Jun 15, 2021

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: amisevsk, kim-tsao

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the lgtm label Jun 15, 2021
@kim-tsao kim-tsao merged commit b0014e0 into devfile:main Jun 15, 2021
@@ -43,6 +43,12 @@ func (devfile *TestDevfile) AddComponent(componentType schema.ComponentType) sch
if componentType == schema.ContainerComponentType {
component = devfile.createContainerComponent()
devfile.SetContainerComponentValues(&component)
} else if componentType == schema.KubernetesComponentType {
component = devfile.createKubernetesComponent()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking perhaps we don't need to split those component creation into sub function calls.
Those function call are almost identical, except for the part of creating an empty component.
can combine those sub function calls within this AddComponent

Suggested change
component = devfile.createKubernetesComponent()
func (devfile *TestDevfile) AddComponent(componentType schema.ComponentType) schema.Component {
LogInfoMessage("Create a %v component :", componentType)
component := schema.Component{}
component.Name = GetRandomUniqueString(8, true)
LogInfoMessage(fmt.Sprintf("....... Name: %s", component.Name))
switch componentType{
case schema.ContainerComponentType:
component.Container = &schema.ContainerComponent{}
devfile.SetContainerComponentValues(&component)
...... // cases for other component types
}
devfile.componentAdded(component)
return component
}

Same for AddCommand

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kim-tsao I guess I'm late for this PR..

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yangcao77 sorry I missed this! I appreciate your feedback anyhow so I'll try to apply your suggestion next time, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants