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

feat: pkg-util-kubectl Enhancement #861

Merged
merged 1 commit into from
Jul 18, 2022

Conversation

jxs1211
Copy link
Contributor

@jxs1211 jxs1211 commented Jul 18, 2022

Signed-off-by: xian-jie.shen 327411586@qq.com

Pre-Checklist

Note: please complete ALL items in the following checklist.

  • I have read through the CONTRIBUTING.md documentation.
  • My code has the necessary comments and documentation (if needed).
  • I have added relevant tests

Description

  • try to add ut for the package

Related Issues

see #833 for the details

New Behavior (screenshots if needed)

[going@dev kubectl]$ go test -race -cover  -coverprofile=./coverage.out -timeout=10m -short -v
=== RUN   TestKubeCreate
=== RUN   TestKubeCreate/base
2022-07-18 09:04:50 !! [ERROR]  Failed to exec: < /usr/local/bin/kubectl create -f nginx-deployment.yaml >.
2022-07-18 09:04:50 !! [ERROR]  Exec logs: < The connection to the server localhost:8080 was refused - did you specify the right host or port?
 >. Got error: exit status 1.
--- PASS: TestKubeCreate (0.07s)
    --- PASS: TestKubeCreate/base (0.07s)
=== RUN   TestKubeApply
=== RUN   TestKubeApply/base
2022-07-18 09:04:50 !! [ERROR]  Failed to exec: < /usr/local/bin/kubectl apply -f nginx-deployment.yaml >.
2022-07-18 09:04:50 !! [ERROR]  Exec logs: < The connection to the server localhost:8080 was refused - did you specify the right host or port?
 >. Got error: exit status 1.
--- PASS: TestKubeApply (0.06s)
    --- PASS: TestKubeApply/base (0.06s)
=== RUN   TestKubeDelete
=== RUN   TestKubeDelete/base
2022-07-18 09:04:50 !! [ERROR]  Failed to exec: < /usr/local/bin/kubectl delete -f nginx-deployment.yaml >.
2022-07-18 09:04:50 !! [ERROR]  Exec logs: < error: the path "nginx-deployment.yaml" does not exist
 >. Got error: exit status 1.
--- PASS: TestKubeDelete (0.05s)
    --- PASS: TestKubeDelete/base (0.05s)
=== RUN   Test_kubectlAction
=== RUN   Test_kubectlAction/base
2022-07-18 09:04:50 !! [ERROR]  Failed to exec: < /usr/local/bin/kubectl apply -f nginx-deployment.yaml >.
2022-07-18 09:04:50 !! [ERROR]  Exec logs: < The connection to the server localhost:8080 was refused - did you specify the right host or port?
 >. Got error: exit status 1.
--- PASS: Test_kubectlAction (0.06s)
    --- PASS: Test_kubectlAction/base (0.06s)
PASS
coverage: 81.8% of statements

Signed-off-by: xian-jie.shen <327411586@qq.com>
@jxs1211 jxs1211 requested a review from a team as a code owner July 18, 2022 01:14
@jxs1211
Copy link
Contributor Author

jxs1211 commented Jul 18, 2022

@HXCGIT @steinliber my local environment doesn't have kubectl cmd so that the test case can't cover the left part below, how do you think about this circumstance, should we try to cover the left part or leave it to something like the e2e test?
image

@xavier-hou
Copy link
Member

@jxs1211 I think we can leave it alone. First, the function is very simple with no complicated and error-prone operations. Besides, it's hard to handle with unit test.

Copy link
Contributor

@steinliber steinliber left a comment

Choose a reason for hiding this comment

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

Great job. Thanks for your test

@daniel-hutao daniel-hutao merged commit 9913416 into devstream-io:main Jul 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants