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