Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/cheekybits/is

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/cheekybits/is

  • v0.0.0-20150225183255-68e9c0620927
  • Source
  • Go
  • Socket score

Version published
Created
Source

is

GoDoc

A mini testing helper for Go.

  • Simple interface (is.OK and is.Equal)
  • Plugs into existing Go toolchain (uses testing.T)
  • Obvious for newcomers and newbs
  • Also gives you is.Panic and is.PanicWith helpers - because testing panics is ugly

Usage

  1. Write test functions as usual
  2. Add is := is.New(t) at top of your test functions
  3. Call target code
  4. Make assertions using new is object
func TestSomething(t *testing.T) {
  is := is.New(t)

  // ensure not nil
  obj := SomeFunc()
  is.OK(obj)

  // ensure no error
  obj, err := SomeFunc()
  is.NoErr(err)

  // ensure not false
  b := SomeBool()
  is.OK(b)

  // ensure not ""
  s := SomeString()
  is.OK(s)

  // ensure not zero
  is.OK(len(something))

  // ensure doesn't panic
  is.OK(func(){
    MethodShouldNotPanic()
  })

  // ensure many things in one go
  is.OK(b, err, obj, "something")

  // ensure something does panic
  is.Panic(func(){
    MethodShouldPanic(1)
  })
  is.PanicWith("package: arg must be >0", func(){
    MethodShouldPanicWithSpecificMessage(0)
  })

  // make sure two values are equal
  is.Equal(1, 2)
  is.Equal(err, ErrSomething)
  is.Equal(a, b)

}

Get started

Get it:

go get github.com/cheekybits/is

Then import it:

import (
  "testing"
  "github.com/cheekybits/is"
)

FAQs

Package last updated on 25 Feb 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc