cute icon indicating copy to clipboard operation
cute copied to clipboard

Please, think about additional assert types

Open ghost opened this issue 3 years ago • 5 comments

Currently we have next asserts:

  • Contains
  • Equal
  • NotEqual
  • Length
  • GreaterThan
  • LessThan
  • Present
  • NotPresent

Please, think to add next assert types:

  • GreaterEqual
  • LessEqual
  • AssertArray

ghost avatar Jul 14 '22 11:07 ghost

It seems that if you add GreaterOrEqualThan then GreaterThan behaviour becomes wrong, it doesn't return an error on Equal case. Also LessOrEqualThen. I could add these features, but then I'd have to break backwards compatibility, right?

shalimski avatar Aug 06 '22 01:08 shalimski

So, now GreaterThani is assert only for array. It's my mistake. I think. if we add comparing(equal) for numbers with error on zero case, it will be ok

siller174 avatar Aug 07 '22 20:08 siller174

I didn't see how that would help. Here is an example of what I was talking about:

assert.Greater(t, 3, 3)                                // testify FAIL "3" is not greater than "3"
GreaterThan("$.o", 3)([]byte(`{"o":["a", "b", "c"]}`)) // ok

So, If you add GreaterOrEqualThan, behaviour of GreaterThan should change to FAIL

shalimski avatar Aug 07 '22 23:08 shalimski

Sorry for long answer. My point is need to copy logic assertion from assert package and implement it. If it will break backwards compatibility, it's ok.

siller174 avatar Aug 15 '22 09:08 siller174

Thank you @shalimski for https://github.com/ozontech/cute/pull/18

siller174 avatar Sep 14 '22 20:09 siller174