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

Increase coverage in assertions #732

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

fokion
Copy link
Contributor

@fokion fokion commented Oct 21, 2023

Adding local json instead of trying to call an http server. Increasing coverage of assertions by adding tests in the ShouldBeMap , ShouldBeArray and fixing the issue with the ShouldNotExist

Signed-off-by: Fokion Sotiropoulos <fokion.s@gmail.com>
… based on the documentation

Signed-off-by: Fokion Sotiropoulos <fokion.s@gmail.com>
Signed-off-by: Fokion Sotiropoulos <fokion.s@gmail.com>
Signed-off-by: Fokion Sotiropoulos <fokion.s@gmail.com>
Comment on lines 266 to +268
func ShouldNotExist(actual interface{}, expected ...interface{}) error {
if ShouldBeNil(actual) != nil ||
ShouldBeBlank(actual) != nil ||
ShouldBeZeroValue(actual) != nil {
return fmt.Errorf("expected not exist but it was")
if ShouldBeNil(actual) != nil && ShouldBeBlank(actual) != nil && ShouldBeZeroValue(actual) != nil {
return fmt.Errorf("expected to be empty but it was not")
Copy link
Member

Choose a reason for hiding this comment

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

Why do you need to update that ?

name: Assertions testsuite
testcases:
- name: test assertion ShouldNotExist
  steps:
  - script: echo ''
    assertions:
    - result.systemoutjson ShouldNotExist 

-->

ShouldBeNil: expected: Nil but is wasn't
ShouldBeBlank: <nil>
ShouldBeZeroValue: <nil> 

--> With your code, the testsuite is PASS, but should be be FAIL

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The documentation of this method specifies the following :

ShouldNotExist receives a single parameter and ensures that it is nil, blank or zero value

I added the parameterised test that checks all these and it was failing when the value was blank similar to the example that you specified. This is means that the method is not working to its specification ( needs to PASS when the value is blank ) , thus the amendment

@fokion fokion requested a review from yesnault October 23, 2023 18:31
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.

None yet

3 participants