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 6 package(s)

  1. github.com/aldor007/stow/test
  2. github.com/etcenter/C4/test
  3. github.com/etcenter/c4/test
  4. github.com/etcenter/c4go/test
  5. github.com/graymeta/stow/test
  6. github.com/matryer/vice/vicetest

Imported only in test by 141 package(s)

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