top

Package assert provides some basic assertion functions for testing and also provides the building blocks for creating your own more complex validations.

package whatever

import (
	"errors"
	"testing"
	. "gopkg.in/go-playground/assert.v1"
)

func AssertCustomErrorHandler(t *testing.T, errs map[string]string, key, expected string) {
	val, ok := errs[key]

	// using EqualSkip and NotEqualSkip as building blocks for my custom Assert function
	EqualSkip(t, 2, ok, true)
	NotEqualSkip(t, 2, val, nil)
	EqualSkip(t, 2, val, expected)
}

func TestEqual(t *testing.T) {

	// error comes from your package/library
	err := errors.New("my error")
	NotEqual(t, err, nil)
	Equal(t, err.Error(), "my error")

	err = nil
	Equal(t, err, nil)

	fn := func() {
		panic("omg omg omg!")
	}

	PanicMatches(t, func() { fn() }, "omg omg omg!")
	PanicMatches(t, func() { panic("omg omg omg!") }, "omg omg omg!")

	// errs would have come from your package/library
	errs := map[string]string{}
	errs["Name"] = "User Name Invalid"
	errs["Email"] = "User Email Invalid"

	AssertCustomErrorHandler(t, errs, "Name", "User Name Invalid")
	AssertCustomErrorHandler(t, errs, "Email", "User Email Invalid")
}

Imported only in test by 122 package(s) ΒΆ

  1. github.com/AntoineFinkelstein/overalls
  2. github.com/AntoineFinkelstein/overalls/test-files/good
  3. github.com/AntoineFinkelstein/overalls/test-files/good2
  4. github.com/AstromechZA/pbars
  5. github.com/HadockHanif/go-trigger
  6. github.com/SuhasAnand/pool
  7. github.com/antoinefinkelstein/overalls
  8. github.com/antoinefinkelstein/overalls/test-files/good
  9. github.com/bookerzzz/validator
  10. github.com/boomshroom/battlesnake-go
  11. github.com/brettbuddin/ponyexpress/server
  12. github.com/brettbuddin/shaden/lisp
  13. github.com/dangBinh/validator
  14. github.com/davidraba/pool
  15. github.com/dgdn/validator
  16. github.com/fdelbos/validator
  17. github.com/gicmo/webhooks
  18. github.com/gicmo/webhooks/bitbucket
  19. github.com/gicmo/webhooks/github
  20. github.com/go-aah/validator
  21. github.com/go-experimental/assets
  22. github.com/go-experimental/bundler
  23. github.com/go-experimental/lars
  24. github.com/go-experimental/lars/middleware
  25. github.com/go-experimental/lars1
  26. github.com/go-experimental/lars2
  27. github.com/go-experimental/lars3
  28. github.com/go-experimental/lcars
  29. github.com/go-experimental/lcars/middleware
  30. github.com/go-experimental/rum
  31. github.com/go-playground/assets
  32. github.com/go-playground/bundler
  33. github.com/go-playground/form
  34. github.com/go-playground/generate
  35. github.com/go-playground/lars
  36. github.com/go-playground/lars/middleware
  37. github.com/go-playground/mold
  38. github.com/go-playground/mold/scrubbers
  39. github.com/go-playground/mongostore
  40. github.com/go-playground/overalls
  41. github.com/go-playground/pool
  42. github.com/go-playground/pure
  43. github.com/go-playground/pure/middleware
  44. github.com/go-playground/statics
  45. github.com/go-playground/statics/static
  46. github.com/go-playground/stats
  47. github.com/go-playground/validator
  48. github.com/go-playground/validator/translations/en
  49. github.com/go-playground/webhooks
  50. github.com/go-playground/webhooks/bitbucket
  51. github.com/go-playground/webhooks/github
  52. github.com/go-playground/webhooks/gitlab
  53. github.com/hartfordfive/log
  54. github.com/james-woo/battlesnake-go
  55. github.com/javinc/validator
  56. github.com/joeybloggs/go-validate-yourself
  57. github.com/joeybloggs/mongo-session-store
  58. github.com/joeybloggs/pool
  59. github.com/joeybloggs/proof-of-concept/allocations
  60. github.com/joeybloggs/statics
  61. github.com/joeybloggs/statics/static
  62. github.com/joeybloggs/stats
  63. github.com/joeybloggs/webhooks
  64. github.com/joeybloggs/webhooks/bitbucket
  65. github.com/joeybloggs/webhooks/github
  66. github.com/josephspurrier/overalls
  67. github.com/kujenga/validator
  68. github.com/moogle19/validator
  69. github.com/muyiwaolurin/lars
  70. github.com/muyiwaolurin/statics
  71. github.com/muyiwaolurin/statics/static
  72. github.com/muyiwaolurin/tri
  73. github.com/muyiwaolurin/tri/middleware
  74. github.com/muyiwaolurin/validator
  75. github.com/naiba/webhooks
  76. github.com/naiba/webhooks/bitbucket
  77. github.com/naiba/webhooks/github
  78. github.com/naiba/webhooks/gitlab
  79. github.com/oxchart/utils
  80. github.com/sadlil/jenctl/pkg
  81. github.com/sadlil/stopwatch
  82. github.com/sadlil/stopwatch/timeunit
  83. github.com/sendwithus/battlesnake-go
  84. github.com/themihai/form
  85. github.com/vkolev/form
  86. github.com/zwh8800/pool
  87. gopkg.in/bluesuncorp/go-validate-yourself.v6
  88. gopkg.in/bluesuncorp/go-validate-yourself.v7
  89. gopkg.in/bluesuncorp/go-validate-yourself.v8
  90. gopkg.in/bluesuncorp/go-validate-yourself.v9
  91. gopkg.in/bluesuncorp/mongo-session-store.v4
  92. gopkg.in/bluesuncorp/mongostore.v4
  93. gopkg.in/bluesuncorp/validator.v6
  94. gopkg.in/bluesuncorp/validator.v7
  95. gopkg.in/bluesuncorp/validator.v8
  96. gopkg.in/bluesuncorp/validator.v9
  97. gopkg.in/go-playground/mongostore.v4
  98. gopkg.in/go-playground/pool.v1
  99. gopkg.in/go-playground/pool.v2
  100. gopkg.in/go-playground/pool.v3
  101. gopkg.in/go-playground/statics.v1
  102. gopkg.in/go-playground/statics.v1/static
  103. gopkg.in/go-playground/stats.v1
  104. gopkg.in/go-playground/validator.v6
  105. gopkg.in/go-playground/validator.v7
  106. gopkg.in/go-playground/validator.v8
  107. gopkg.in/go-playground/validator.v9
  108. gopkg.in/go-playground/validator.v9/translations/en
  109. gopkg.in/go-playground/webhooks.v1
  110. gopkg.in/go-playground/webhooks.v1/bitbucket
  111. gopkg.in/go-playground/webhooks.v1/github
  112. gopkg.in/go-playground/webhooks.v2
  113. gopkg.in/go-playground/webhooks.v2/bitbucket
  114. gopkg.in/go-playground/webhooks.v2/github
  115. gopkg.in/ilgooz/validator.v6
  116. gopkg.in/ilgooz/validator.v7
  117. gopkg.in/ilgooz/validator.v8
  118. gopkg.in/joeybloggs/go-validate-yourself.v6
  119. gopkg.in/joeybloggs/go-validate-yourself.v7
  120. gopkg.in/joeybloggs/go-validate-yourself.v8
  121. gopkg.in/joeybloggs/go-validate-yourself.v9
  122. gopkg.in/joeybloggs/mongo-session-store.v4