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 error checking in tests and enable errcheck there #1980

Merged
merged 21 commits into from
Dec 9, 2024
Merged

Conversation

denik
Copy link
Contributor

@denik denik commented Dec 9, 2024

Changes

Fix all errcheck-found issues in tests and test helpers. Mostly this done by adding require.NoError(t, err), sometimes panic() where t object is not available).

Initial change is obtained with aider+claude, then manually reviewed and cleaned up.

Tests

Existing tests.

@denik denik temporarily deployed to test-trigger-is December 9, 2024 09:12 — with GitHub Actions Inactive
@denik denik changed the title Errcheck tests Fix errcheck in tests Dec 9, 2024
@denik denik temporarily deployed to test-trigger-is December 9, 2024 09:12 — with GitHub Actions Inactive
@denik denik temporarily deployed to test-trigger-is December 9, 2024 09:19 — with GitHub Actions Inactive
@denik denik temporarily deployed to test-trigger-is December 9, 2024 09:19 — with GitHub Actions Inactive
@denik denik temporarily deployed to test-trigger-is December 9, 2024 09:27 — with GitHub Actions Inactive
@denik denik temporarily deployed to test-trigger-is December 9, 2024 09:27 — with GitHub Actions Inactive
denik added 2 commits December 9, 2024 10:29
Note, claude did it because it followed the existing patttern in this function.
@denik denik temporarily deployed to test-trigger-is December 9, 2024 09:32 — with GitHub Actions Inactive
@denik denik temporarily deployed to test-trigger-is December 9, 2024 09:32 — with GitHub Actions Inactive
@denik denik temporarily deployed to test-trigger-is December 9, 2024 09:36 — with GitHub Actions Inactive
@denik denik temporarily deployed to test-trigger-is December 9, 2024 09:36 — with GitHub Actions Inactive
@denik denik temporarily deployed to test-trigger-is December 9, 2024 09:36 — with GitHub Actions Inactive
@denik denik temporarily deployed to test-trigger-is December 9, 2024 09:36 — with GitHub Actions Inactive
@denik denik temporarily deployed to test-trigger-is December 9, 2024 09:45 — with GitHub Actions Inactive
@denik denik temporarily deployed to test-trigger-is December 9, 2024 09:45 — with GitHub Actions Inactive
@denik denik temporarily deployed to test-trigger-is December 9, 2024 09:50 — with GitHub Actions Inactive
@denik denik temporarily deployed to test-trigger-is December 9, 2024 09:50 — with GitHub Actions Inactive
@denik denik temporarily deployed to test-trigger-is December 9, 2024 09:53 — with GitHub Actions Inactive
@denik denik temporarily deployed to test-trigger-is December 9, 2024 09:53 — with GitHub Actions Inactive
@denik denik marked this pull request as ready for review December 9, 2024 09:54
@denik denik changed the title Fix errcheck in tests Add error checking in tests and enable errcheck there Dec 9, 2024
exclude-rules:
- path-except: (_test\.go|internal)
linters:
- errcheck
Copy link
Contributor

Choose a reason for hiding this comment

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

This means it is enabled only for tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it's enabled if path matches this regex (_test.go|internal). It's not obvious from reading the config but I tested that it works like that.

_, err := t.stdinW.Write([]byte(text + "\n"))
if err != nil {
panic("Failed to to write to t.stdinW")
}
Copy link
Contributor

Choose a reason for hiding this comment

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

t embeds *testing.T, so you can use require.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That file uses panic() in 2 other places, so I'm just following how it's done here. We can update all at once later.

Copy link
Contributor

Choose a reason for hiding this comment

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

Makes sense, thanks.

@@ -156,7 +156,8 @@ func TestRootMergeTargetOverridesWithVariables(t *testing.T) {
},
},
}
root.initializeDynamicValue()
require.NoError(t, root.initializeDynamicValue())

Copy link
Contributor

Choose a reason for hiding this comment

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

NL

@denik denik temporarily deployed to test-trigger-is December 9, 2024 10:08 — with GitHub Actions Inactive
@denik denik enabled auto-merge December 9, 2024 10:08
@denik denik temporarily deployed to test-trigger-is December 9, 2024 10:08 — with GitHub Actions Inactive
@denik denik temporarily deployed to test-trigger-is December 9, 2024 10:50 — with GitHub Actions Inactive
@denik denik temporarily deployed to test-trigger-is December 9, 2024 10:50 — with GitHub Actions Inactive
@denik denik disabled auto-merge December 9, 2024 11:39
@denik denik temporarily deployed to test-trigger-is December 9, 2024 11:40 — with GitHub Actions Inactive
Copy link

github-actions bot commented Dec 9, 2024

If integration tests don't run automatically, an authorized user can run them manually by following the instructions below:

Trigger:
go/deco-tests-run/cli

Inputs:

  • PR number: 1980
  • Commit SHA: 9f5abc465756a02d341d4dc5384190da5bd3a926

Checks will be approved automatically on success.

@denik denik temporarily deployed to test-trigger-is December 9, 2024 11:40 — with GitHub Actions Inactive
@eng-dev-ecosystem-bot
Copy link
Collaborator

Test Details: go/deco-tests/12234884650

@denik denik enabled auto-merge December 9, 2024 11:49
@denik denik disabled auto-merge December 9, 2024 12:56
@denik denik merged commit 1b2be1b into main Dec 9, 2024
10 of 11 checks passed
@denik denik deleted the errcheck-tests branch December 9, 2024 12:56
@denik
Copy link
Contributor Author

denik commented Dec 9, 2024

Merging -there was one integration test failing, due to API quotas.

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.

3 participants