Coder Social home page Coder Social logo

goodman's Introduction

Goodman Godoc Reference Travis Status

Goodman is a Dredd hook handler implementation in Go. The API may change, please Vendor this library.

About

This package contains a Go Dredd hook handler which provides a bridge between the Dredd API Testing Framework and Go environment to ease implementation of testing hooks provided by Dredd. Write Dredd hooks in Go to glue together API Blueprint with your Go project

Not sure what these Dredd Hooks are? Read the Dredd documentation on them

The following are a few examples of what hooks can be used for:

  • loading db fixtures
  • cleanup after test step or steps
  • handling authentication and sessions
  • passing data between transactions (saving state from responses to stash)
  • modifying request generated from blueprint
  • changing generated expectations
  • setting custom expectations
  • debugging via logging stuff

Installing

Must use Dredd v1.1.0 or greater

go get github.com/snikch/goodman/cmd/goodman

Usage

1). Create a hook file in hooks.go

package main

import (
  "fmt"

  "github.com/snikch/goodman/hooks"
  trans "github.com/snikch/goodman/transaction"
)

func main() {
      h := hooks.NewHooks()
      server := hooks.NewServer(hooks.NewHooksRunner(h))
      h.Before("/message > GET", func(t *trans.Transaction) {
          fmt.Println("before modification")
      })
      server.Serve()
      defer server.Listener.Close()
})

2). Compile your hooks program

go build -o hooks path/to/hooks.go

3). Run it with dredd

dredd apiary.apib localhost:3000 --language go --hookfiles ./hooks

API

The hooks.Server struct provides the following methods to hook into the following dredd transactions: before, after, before_all, after_all, before_each, after_each, before_validation, and before_each_validation. The before, before_validation and after hooks are identified by transaction name.

How to Contribute

  1. Fork it
  2. Create your feature branch (git checkout -b my-newfeature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push (git push origin my-new-feature)
  5. Create a new Pull Request

Tests

The test suite consists of go test suite and aruba/cucumber tests

Running the tests

  • go tests go test github.com/snikch/{,/hooks,/transaction}

  • aruba tests

    • Install local dredd copy npm install
    • Install aruba ruby gem bundle install
    • Run test suite bundle exec cucumber

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.