Skip to content

[usage] Fix test for listing usage with pagination #12562

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

Merged
merged 1 commit into from
Aug 31, 2022
Merged

Conversation

easyCZ
Copy link
Member

@easyCZ easyCZ commented Aug 31, 2022

Description

There are test hooks for record deletion. However, these wouldn't run after each test when the test setup up was hooked up to the top level *testing.T (because the hook would only run after they finished). Instead, we need to bind the hooks to each subtest.

Related Issue(s)

Fixes unit tests from #12562

How to test

unit tests

Release Notes

NONE

Documentation

Werft options:

  • /werft with-preview

@easyCZ easyCZ requested a review from a team August 31, 2022 19:01
@github-actions github-actions bot added the team: webapp Issue belongs to the WebApp team label Aug 31, 2022
@@ -204,112 +201,87 @@ func TestUsageService_ListBilledUsage_Pagination(t *testing.T) {
}

scenarios := []Scenario{
(func() Scenario {
Copy link
Member Author

Choose a reason for hiding this comment

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

This wrapping in a self-invoking anonymous function isn't needed. It would be useful we wanted to do some imperative work, but we're doing only declarative statements.

Copy link
Member

Choose a reason for hiding this comment

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

💡 thanks 💯

@@ -175,11 +175,8 @@ func TestUsageService_ListBilledUsage_Pagination(t *testing.T) {
ctx := context.Background()

type Expectation struct {
count int64
Copy link
Member Author

Choose a reason for hiding this comment

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

these properties were not used in the test anywhere...

@AlexTugarev AlexTugarev self-assigned this Aug 31, 2022
@werft-gitpod-dev-com
Copy link

started the job as gitpod-build-mp-usage-fix-tests.1 because the annotations in the pull request description changed
(with .werft/ from main)

Copy link
Member

@AlexTugarev AlexTugarev left a comment

Choose a reason for hiding this comment

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

Awesome!
Nice lesson.

@roboquat roboquat merged commit 1c3090f into main Aug 31, 2022
@roboquat roboquat deleted the mp/usage-fix-tests branch August 31, 2022 19:58
@roboquat roboquat added deployed: webapp Meta team change is running in production deployed Change is completely running in production labels Sep 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deployed: webapp Meta team change is running in production deployed Change is completely running in production release-note-none size/L team: webapp Issue belongs to the WebApp team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants