Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

More cmd package unit tests #2997

Merged
merged 12 commits into from
May 21, 2018
Merged

Conversation

CecileRobertMichon
Copy link
Contributor

@CecileRobertMichon CecileRobertMichon commented May 17, 2018

What this PR does / why we need it:

Which issue this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close that issue when PR gets merged): fixes #2913

Special notes for your reviewer:

If applicable:

  • documentation
  • unit tests
  • tested backward compatibility (ie. deploy with previous version, upgrade with this branch)

Release note:

@ghost ghost added the in progress label May 17, 2018
@Azure Azure deleted a comment from acs-bot May 17, 2018
@acs-bot
Copy link

acs-bot commented May 17, 2018

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
To fully approve this pull request, please assign additional approvers.
We suggest the following additional approver: cecilerobertmichon

Assign the PR to them by writing /assign @cecilerobertmichon in a comment when ready.

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

The pull request process is described 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

@codecov
Copy link

codecov bot commented May 17, 2018

Codecov Report

Merging #2997 into master will increase coverage by 0.56%.
The diff coverage is 27.11%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2997      +/-   ##
==========================================
+ Coverage   50.74%   51.31%   +0.56%     
==========================================
  Files          97       97              
  Lines       14689    14688       -1     
==========================================
+ Hits         7454     7537      +83     
+ Misses       6536     6450      -86     
- Partials      699      701       +2
Impacted Files Coverage Δ
cmd/upgrade.go 28.45% <0%> (-1.63%) ⬇️
cmd/orchestrators.go 77.27% <100%> (+45.45%) ⬆️
cmd/scale.go 12.92% <20.45%> (+12.92%) ⬆️
cmd/deploy.go 42.48% <50%> (+18.01%) ⬆️
cmd/root.go 14.51% <0%> (-11.3%) ⬇️
pkg/operations/kubernetesupgrade/upgrader.go 56.66% <0%> (-0.84%) ⬇️
pkg/api/vlabs/validate.go 45.88% <0%> (+0.18%) ⬆️
cmd/generate.go 47.61% <0%> (+15.23%) ⬆️
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 388f58f...441a7f9. Read the comment docs.

@acs-bot acs-bot added the size/L label May 17, 2018
return nil
}

func (dc *deployCmd) load(cmd *cobra.Command, args []string) error {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

small refactor here -> split validate and load into two separate functions

@@ -72,6 +73,123 @@ func getAPIModelWithoutServicePrincipalProfile(baseAPIModel string, useManagedId
strconv.FormatBool(useManagedIdentity))
}

func TestNewDeployCmd(t *testing.T) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

unit_test_coverage++

@CecileRobertMichon
Copy link
Contributor Author

CecileRobertMichon commented May 17, 2018

/lgtm

(testing the bot)

@acs-bot
Copy link

acs-bot commented May 17, 2018

@CecileRobertMichon: you cannot LGTM your own PR.

In response to this:

/lgtm

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@@ -100,21 +85,6 @@ var _ = Describe("the upgrade command", func() {
deploymentDirectory: "_output/mydir",
upgradeVersion: "1.9.0",
location: "southcentralus",
authArgs: authArgs{},
},
expectedErr: fmt.Errorf("--subscription-id is required (and must be a valid UUID)"),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved validateAuthArgs to load() so we don't check for subID in validate anymore

@CecileRobertMichon CecileRobertMichon changed the title WIP cmd package unit tests More cmd package unit tests May 17, 2018
cmd/scale.go Outdated
}

func (sc *scaleCmd) run(cmd *cobra.Command, args []string) error {
sc.validate(cmd, args)
if err := sc.validate(cmd); err != nil {
log.Fatalln("failed to validate scale command: %s", err.Error())
Copy link
Member

Choose a reason for hiding this comment

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

we don't want to return here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we do... I left the run function for another day because it has a ton of those but I'll fix that one since I added it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nevermind I just fixed all of them

@jackfrancis
Copy link
Member

/lgtm

@acs-bot acs-bot added the lgtm label May 21, 2018
@jackfrancis jackfrancis merged commit 3482257 into Azure:master May 21, 2018
@ghost ghost removed the awaiting review label May 21, 2018
@CecileRobertMichon CecileRobertMichon deleted the cmd-unit-tests branch June 6, 2018 19:13
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

clean up error handling and logging, e.g. in scale.go
3 participants