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
base: master
Are you sure you want to change the base?
Conversation
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>
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") |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
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 theShouldNotExist