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

Fix unit test failures with go 1.15 #1214

Merged
merged 1 commit into from
Oct 22, 2020

Conversation

shuheiktgw
Copy link
Contributor

@shuheiktgw shuheiktgw commented Oct 21, 2020

Changes

Closes #1202

It seems from go 1.15, the error message has been slightly changed and it is quoted now. Why don't we use a prefix match to test if the error messages are as expected?

Submitter Checklist

These are the criteria that every PR should meet, please check them off as you
review them:

  • Includes tests (if functionality changed/added)
  • Run the code checkers with make check
  • Regenerate the manpages, docs and go formatting with make generated
  • Commit messages follow commit message best practices

See the contribution guide
for more details.

none

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Oct 21, 2020

CLA Check
The committers are authorized under a signed CLA.

  • ✅ Shuhei Kitagawa (4b2f39750b0fbf14b7f18c2c056fc74ef54f3447)

@tekton-robot tekton-robot added the do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. label Oct 21, 2020
@tekton-robot
Copy link
Contributor

Hi @shuheiktgw. Thanks for your PR.

I'm waiting for a tektoncd member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@tekton-robot tekton-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Oct 21, 2020
@shuheiktgw
Copy link
Contributor Author

It seems easycla dies with some JS errors so let me try signing it later again

@danielhelfand
Copy link
Member

/ok-to-test

@tekton-robot tekton-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Oct 21, 2020
Copy link
Member

@danielhelfand danielhelfand left a comment

Choose a reason for hiding this comment

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

Thanks for the pr @shuheiktgw!

Comment on lines 1626 to 1633
if !strings.HasPrefix(err.Error(), tp.want) {
t.Errorf("unexpected output: expected prefix: %s, actual: %s", tp.want, 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.

Maybe for continuity of the existing tests, it would make sense to add a field to tp (maybe a boolean named hasPrefix). If hasPrefix is true, this new check you have added takes place. If hasPrefix is false, then test.AssertOutput(t, tp.want, err.Error()) is executed.

Additionally, what if this is defined as a helper func in helper.go and followed a similar output format for errors as AssertOutput?

What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds great! Let me fix the code quickly 😃

@danielhelfand
Copy link
Member

Another thing to make note of with regard to #1202 is the following error:

pkg/formatted/color_test.go:42:10: conversion from int to string yields a string of one rune, not a string of digits (did you mean fmt.Sprint(x)?)

This is happening in color_test.go and can be resolved as follows:

for c := range palette {
    a := strconv.Itoa(c)
    rb.get(a)
}

@tekton-robot tekton-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Oct 21, 2020
@shuheiktgw
Copy link
Contributor Author

I'm looking into color_test.go now

@shuheiktgw shuheiktgw changed the title Fix unit test failures with go 1.5 Fix unit test failures with go 1.15 Oct 21, 2020
@shuheiktgw
Copy link
Contributor Author

@danielhelfand Thank you for your review! I've fixed the PR so would you review it again? 🙏

Copy link
Member

@danielhelfand danielhelfand left a comment

Choose a reason for hiding this comment

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

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Oct 22, 2020
@danielhelfand
Copy link
Member

@shuheiktgw Could you please also squash your commits into a single commit?

@tekton-robot tekton-robot removed the lgtm Indicates that a PR is ready to be merged. label Oct 22, 2020
@shuheiktgw
Copy link
Contributor Author

@danielhelfand Sure, I've squashed the commits so please check it!

Copy link
Member

@danielhelfand danielhelfand left a comment

Choose a reason for hiding this comment

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

/lgtm

@shuheiktgw Thank you! Just needs another review from someone else.

@tekton-robot tekton-robot added lgtm Indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesnt merit a release note. labels Oct 22, 2020
@tekton-robot tekton-robot removed the do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. label Oct 22, 2020
Copy link
Contributor

@piyush-garg piyush-garg left a comment

Choose a reason for hiding this comment

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

/lgtm

@tekton-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: piyush-garg

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

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 22, 2020
@tekton-robot tekton-robot merged commit 755923e into tektoncd:master Oct 22, 2020
pradeepitm12 added a commit that referenced this pull request Nov 16, 2020
#1215 | [Piyush Garg] Update readme for 0.13.1 and fix lint task | 2020/10/21-14:41
#1210 | [Daniel Helfand] common way of referring to tekton resources in user facing messages: ClusterTriggerBinding | 2020/10/21-15:55
#1209 | [Daniel Helfand] common way of referring to tekton resources in user facing messages: Condition | 2020/10/21-17:41
#1213 | [Daniel Helfand] common way of referring to tekton resources in user facing messages: TriggerTemplate | 2020/10/21-19:33
#1214 | [shuheiktgw] Fix unit test failures with go 1.15 | 2020/10/22-04:19
#1203 | [Sunil Thaha] Integrate Hub commands into tkn | 2020/10/22-04:41
#1217 | [Daniel Helfand] fix alignment of usage | 2020/10/22-18:47
#1218 | [Daniel Helfand] document NO_COLOR and edit README headers | 2020/10/26-15:40
#1224 | [Daniel Helfand] change --nocolour to --no-color | 2020/10/28-02:57
#1221 | [SM43] Updates Hub Dependency | 2020/10/28-04:51
null | [Daniel Helfand] deprecate -c shorthand for tkn version --check | 2020/11/03-15:37
null | [Pradeep Kumar] Bump pipeline and triggers deps | 2020/11/04-20:12
null | [Daniel Helfand] do not delete clustertask taskruns with --task flag | 2020/11/04-20:59
null | [Piyush Garg] Fix APIversion not shown on describe commands | 2020/11/05-10:54
null | [Pratik Jagrut] Add --all-namespaces flag to tkn triggerbinding list command | 2020/11/06-12:25
null | [Pratik Jagrut] Add --all-namespaces flag to tkn eventlistener list command | 2020/11/06-16:04
null | [vinamra28] Add --all-namespaces flag to TriggerTemplate List subcommand | 2020/11/06-19:39
null | [Chmouel Boudjnah] Make sure we target LTS for ubuntus | 2020/11/06-21:12
null | [Pratik Jagrut] Add --all-namespaces flag to tkn condition list command | 2020/11/09-14:14
null | [Daniel Helfand] remove EventListener log output assertion from e2e tests | 2020/11/11-16:52
null | [Pradeep Kumar] bump pipleine dependency to v0.18.0 | 2020/11/12-11:28
null | [dullest] fix function name typo | 2020/11/12-15:17
null | [Vincent Demeester] Makefile: remove darwin/386 from cross target 🌮 | 2020/11/13-15:58
null | [Pratik Jagrut] Add --no-headers flag to tkn clustertask list command | 2020/11/16-09:50
null | [Pratik Jagrut] Add --no-headers flag to tkn clustertriggerbinding list command | 2020/11/16-10:24

Signed-off-by: Pradeep Kumar <pradkuma@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note-none Denotes a PR that doesnt merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unit Test Failures with go 1.15
4 participants