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

Adding tests for internal_workflow_client #1349

Merged

Conversation

dkrotx
Copy link
Member

@dkrotx dkrotx commented Jun 22, 2024

Added tests for internal_workflow_client

To increase code coverage

unit-tests

no risk

@dkrotx dkrotx force-pushed the coverage-internal_workflow_client branch 2 times, most recently from 50669f4 to 459d9f9 Compare June 23, 2024 10:33
dkrotx added 3 commits June 23, 2024 12:36
Without this mocks are not verified as expected
(every table-test case'). While this would work, one might expect
behavior like
```
for _, tt := range testcases {
    t.Run(tt.name, func(t* testing.T) {
        init-controller-and-mocks
        // test-code
        // mocks are verified here, at the end of subtest
    }
}
```
Unfortunately, that's not the behavior you
get with `s.Run(subtest func())` as controller is not re-initialized.

In order to addres this gap testify introduced `SetupSubTest/TearDownSubTest` in v1.8.2
See stretchr/testify#1246 for more details

SubTest behavior was fixed in v1.9.0 - otherwise failed mock
expectations made parent test to fail, but child still succeeded.
See stretchr/testify#1471 for more details
Basically copy-pasting the previous test for ListOpenWorkflow  - those
functions are look alike.
@dkrotx dkrotx force-pushed the coverage-internal_workflow_client branch from 459d9f9 to 9a29436 Compare June 23, 2024 10:39
dkrotx added 2 commits June 23, 2024 13:18
More tests to increase coverage of internal_workflow_client.go to 90%
Table tests for compactness.
Failure cases do not check for input, just return error (this way it is
less excessive).
@dkrotx dkrotx marked this pull request as ready for review June 24, 2024 08:59
Copy link
Contributor

@3vilhamster 3vilhamster left a comment

Choose a reason for hiding this comment

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

LGTM.

Make common-fields check more explicit (actually, only required once, in
happy-path).
ExpectRPC always correlates with requestValidator
@dkrotx dkrotx merged commit 4736cb0 into cadence-workflow:master Jun 24, 2024
11 checks passed
mrombout pushed a commit to softsense/cadence-client that referenced this pull request Feb 26, 2025
Also Upgraded testify to get correct behaviour for subtests (table-tests)
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.

2 participants