top

Package is is a mini testing helper.

func TestSomething(t *testing.T) {
  is := is.New(t)
  obj, err := MethodBeingTested()
  is.OK(obj, err) // list of objects, all must be OK
  is.Equal(obj, "Hello world")
}

OK

is.OK asserts that the specified object is OK, which means different things for different types:

bool  - OK means not false
int   - OK means not zero
error - OK means nil
string - OK means not ""
func() - OK means does not panic
everything else - OK means not nil

Equality

is.Equal asserts that two objects are effectively equal.

Panics

is.Panic and is.PanicWith asserts that the func() will panic. PanicWith specifies the panic text that is expected:

func TestInvalidArgs(t *testing.T) {
  is := is.New(t)
  is.Panic(func(){
    SomeMethod(1)
  })
  is.PanicWith("invalid args, both cannot be nil", func(){
    OtherMethod(nil, nil)
  })
}

Relaxed

To prevent is from stopping when the first assertion fails, you can use is.Relaxed(t), rather than is.New(t).

func TestManyThings(t *testing.T) {
  is := is.Relaxed(t)
  thing, err := Something();
  is.OK(thing)
  is.Nil(err)
  another, err := Another();
  is.Nil(another)
  is.Err(err)
  // all assertions will be tried
}

Imported by 4 package(s)

  1. github.com/etcenter/C4/test
  2. github.com/etcenter/c4/test
  3. github.com/etcenter/c4go/test
  4. github.com/graymeta/stow/test

Imported only in test by 112 package(s)

  1. github.com/Avalanche-io/pathstack
  2. github.com/Avalanche-io/sled
  3. github.com/BytemarkHosting/bytemark-client/cmd/bytemark
  4. github.com/BytemarkHosting/bytemark-client/cmd/bytemark/util
  5. github.com/BytemarkHosting/bytemark-client/lib
  6. github.com/BytemarkHosting/bytemark-client/lib/brain
  7. github.com/RealImage/go-ipfs-api
  8. github.com/Ripounet/goblueprints/chapter7/meander
  9. github.com/abaril/GoLights
  10. github.com/abaril/GoLights/api
  11. github.com/ashb/jq-repl/jq
  12. github.com/ashb/jqrepl/jq
  13. github.com/cheekybits/argonauts/csvtojson/go
  14. github.com/cheekybits/argonauts/jsonio
  15. github.com/cheekybits/argonauts/jsontrans/go
  16. github.com/cheekybits/gennylib/maps
  17. github.com/cheekybits/godo/do
  18. github.com/cheekybits/jobs
  19. github.com/cheekybits/m
  20. github.com/cheekybits/model
  21. github.com/cheekybits/parse
  22. github.com/cheekybits/west
  23. github.com/cheekybits/west/example
  24. github.com/cryptix/exp/git
  25. github.com/cryptix/wav
  26. github.com/dahernan/m
  27. github.com/dmikalova/practice/programming-blueprints/meander
  28. github.com/etcenter/C4/asset
  29. github.com/etcenter/C4/db
  30. github.com/etcenter/C4/env
  31. github.com/etcenter/c4/asset
  32. github.com/etcenter/c4/db
  33. github.com/etcenter/c4/env
  34. github.com/etcenter/c4go/asset
  35. github.com/etcenter/c4go/db
  36. github.com/etcenter/c4go/env
  37. github.com/ggicci/respond
  38. github.com/ggicci/respond/encoding
  39. github.com/goestoeleven/goblueprints/chapter7/meander
  40. github.com/graymeta/stow
  41. github.com/graymeta/stow/azure
  42. github.com/graymeta/stow/google
  43. github.com/graymeta/stow/local
  44. github.com/graymeta/stow/oracle
  45. github.com/graymeta/stow/s3
  46. github.com/graymeta/stow/swift
  47. github.com/hatchling/try
  48. github.com/ipfs/go-ipfs-api
  49. github.com/ipfs/go-ipfs-shell
  50. github.com/jasonhancock/hmiddle
  51. github.com/keiwt/goblueprints/meander
  52. github.com/keks/go-ipfs-api
  53. github.com/kogai/goblueprints/chapter7/meander
  54. github.com/konami99/socialpoll/meander
  55. github.com/kriox26/goblueprints/chapter7/meander
  56. github.com/leonardyp/persist
  57. github.com/matryer/anno
  58. github.com/matryer/anno/emoji
  59. github.com/matryer/anno/web
  60. github.com/matryer/articles/decoding
  61. github.com/matryer/flower
  62. github.com/matryer/goblueprints/chapter7/meander
  63. github.com/matryer/m
  64. github.com/matryer/mix
  65. github.com/matryer/persist
  66. github.com/matryer/respond
  67. github.com/matryer/respond/encoding
  68. github.com/matryer/resync
  69. github.com/matryer/runner
  70. github.com/matryer/silk/parse
  71. github.com/matryer/silk/runner
  72. github.com/matryer/str
  73. github.com/matryer/temple
  74. github.com/matryer/try
  75. github.com/mattdotmatt/silk/parse
  76. github.com/mattdotmatt/silk/runner
  77. github.com/mhamrah/goblueprints/chapter7/meander
  78. github.com/muesli/goblueprints/chapter7/meander
  79. github.com/nkovacs/respond
  80. github.com/nkovacs/respond/encoding
  81. github.com/odwrtw/resync
  82. github.com/oldenbur/goblueprints/chapter7/meander
  83. github.com/onufert/randomrec/meander
  84. github.com/oreilly-japan/go-programming-blueprints/chapter7/meander
  85. github.com/padster/wav
  86. github.com/rubenv/osmtopo/osmtopo
  87. github.com/rubenv/osmtopo/osmtopo/needidx
  88. github.com/rubenv/topojson
  89. github.com/sgmac/goblueprints/meander
  90. github.com/stoplightio/m
  91. github.com/telyn/form
  92. github.com/telyn/form/box
  93. github.com/tripism/temple
  94. github.com/ukai/go-programming-blueprints/chapter7/meander
  95. github.com/whyrusleeping/ipfs-shell
  96. github.com/yiwangbaidu/wav
  97. github.com/yiziz/silk/parse
  98. github.com/yiziz/silk/runner
  99. github.com/zbindenren/respond
  100. github.com/zbindenren/respond/encoding
  101. github.com/zignig/go-ipfs-api
  102. gopkg.in/BytemarkHosting/bytemark-client.v0/lib
  103. gopkg.in/BytemarkHosting/bytemark-client.v1/lib
  104. gopkg.in/downlist/mix.v1
  105. gopkg.in/downlist/mix.v2
  106. gopkg.in/matryer/fold.v1
  107. gopkg.in/matryer/mix.v1
  108. gopkg.in/matryer/mix.v2
  109. gopkg.in/matryer/respond.v1
  110. gopkg.in/matryer/respond.v1/encoding
  111. gopkg.in/matryer/str.v1
  112. gopkg.in/matryer/try.v1