-
Notifications
You must be signed in to change notification settings - Fork 263
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
fix(service update): Print success message after successful update #169
fix(service update): Print success message after successful update #169
Conversation
Hmm, I really don't understand how test coverage could decrease with this PR:
But no idea how @knative-metrics-robots measure coverage. Nevertheless, I question the result. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Ok, I see. Because I removed also two lines which were already covered, therefore the coverage dropped
is true as along |
@@ -55,19 +56,19 @@ func NewServiceUpdateCommand(p *commands.KnParams) *cobra.Command { | |||
} | |||
service = service.DeepCopy() | |||
|
|||
err = editFlags.Apply(service, cmd) | |||
if err != nil { | |||
if err = editFlags.Apply(service, cmd); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dont think we are switching to the collapsed style judging by the rest of the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fair point, shouldn't touch existing code for good (aka better) reasons.
@@ -108,6 +109,10 @@ func TestServiceUpdateImage(t *testing.T) { | |||
} else if template.Spec.DeprecatedContainer.Image != "gcr.io/foo/quux:xyzzy" { | |||
t.Fatalf("wrong image set: %v", template.Spec.DeprecatedContainer.Image) | |||
} | |||
|
|||
if !strings.Contains(output, "update") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might as well test fuller message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will anchor on some more keywords here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rhuss why no just expect what is being printed "Service '...' updated in namespace ..."?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because I want to focus on the important context provided by an error message, not on the exact wording. That's why I don't do == assert on error/success messages. That also helps me in focussing on what should be contained in good messages:
- All context available at that point in code (i.e. the input parameters of the method)
- A suggestion how to get over an error (if its an error message)
- Keyword of what has happened, reflecting the action performed ("update").
Side effect: Your tests become more robust as they don't depend on the exact wording and whether there is a comma or not (except you insist on that). In TDD world you would first write the test with the things you would expect to be included in the message, and then write the message. Not write the message first and just blindly check for it (that test doesn't hasn't much expressiveness anyway)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rhuss one of the important aspects of a test is readability. personally i dont find following code readable because its intent is not clear. it also ends up more fragile as it may produce false positives.
if !strings.Contains(strings.ToLower(output), "update") ||
!strings.Contains(output, "foo") ||
!strings.Contains(strings.ToLower(output), "service") ||
!strings.Contains(strings.ToLower(output), "namespace") ||
!strings.Contains(output, "bar") {
t.Fatalf("wrong or no success message: %s", output)
}
however preferred style of these types of assertions is quite subjective so i wont dwell on it too much.
The following is the coverage report on pkg/.
|
@cppforlife Anything else missing for this PR to get merged ? |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: cppforlife, navidshaikh, rhuss 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 |
…native#169) * fix(service update): Print success message after successful update * chore(service update): Improve test, revert unneeded changes
Implements Kn plugins re-using some code from kubectl plugins. This is WIP to allow concrete discussions and testing and hopefully also allow sub tasks to be created and worked on in parallel. This version contains the following: 1. wraps the main root Kn command to support plugin 2. plugins are any executable in PATH with name kn-* 3. 'kn plugins list' to list found kn plugins 4. skips any kn plugins found with name that match core commands, e.g., kn-service would be ignored 5. execute any valid kn plugins found And is missing: 1. unit and integration tests 2. plugin install command 3. plugin repository command 4. plugin / Knative server version negotiation 5. anything else we agree on in plugin req doc Adds a Golang version of e2e Basic workflow that can execute locally (knative#121) 1. creates a namespace 'kne2etests' (default name, change with env KN_E2E_NAMESPACE) 2. executes kn commands as per Basic workflow doc in said namespace 3. verifies each command's output 4. deletes the 'kne2etests' namespace Fix typo in README.md (knative#181) Renames service 'get' to 'list' (knative#179) * Renames service 'get' to 'list' As per title. * Renames get references to list in e2e tests * Replaces get to list in docs Renames revision 'get' to 'list' (knative#180) * Renames revision 'get' to 'list' As per title. * Renames revision get references to revision list in docs feat(build.sh) - Add mandatory license check (knative#187) We could decide to make that optional, too, if this is coming into the way. Chore: Fix typos in docs (knative#178) fix(service update): Print success message after successful update (knative#169) * fix(service update): Print success message after successful update * chore(service update): Improve test, revert unneeded changes [WIP] Kn plugins implementation Implements Kn plugins re-using some code from kubectl plugins. This is WIP to allow concrete discussions and testing and hopefully also allow sub tasks to be created and worked on in parallel. This version contains the following: 1. wraps the main root Kn command to support plugin 2. plugins are any executable in PATH with name kn-* 3. 'kn plugins list' to list found kn plugins 4. skips any kn plugins found with name that match core commands, e.g., kn-service would be ignored 5. execute any valid kn plugins found 6. started adding UTs for plugin commands and files 7. rebased with latest HEAD And is missing: 1. integration tests 2. plugin install command 3. plugin repository command 4. plugin / Knative server version negotiation 5. anything else we agree on in plugin req doc
No description provided.