chain.go 630 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. package httpexpect
  2. type chain struct {
  3. reporter Reporter
  4. failbit bool
  5. }
  6. func makeChain(reporter Reporter) chain {
  7. return chain{reporter, false}
  8. }
  9. func (c *chain) failed() bool {
  10. return c.failbit
  11. }
  12. func (c *chain) fail(message string, args ...interface{}) {
  13. if c.failbit {
  14. return
  15. }
  16. c.failbit = true
  17. c.reporter.Errorf(message, args...)
  18. }
  19. func (c *chain) reset() {
  20. c.failbit = false
  21. }
  22. func (c *chain) assertFailed(r Reporter) {
  23. if !c.failbit {
  24. r.Errorf("expected chain is failed, but it's ok")
  25. }
  26. }
  27. func (c *chain) assertOK(r Reporter) {
  28. if c.failbit {
  29. r.Errorf("expected chain is ok, but it's failed")
  30. }
  31. }