GithubHelp home page GithubHelp logo

goodman's Introduction

Goodman Godoc Reference

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

Usage

Write your own goodman server, and run it as the --language argument to Dredd. Note, you'll need to supply an arbitrary --hookfiles param, this is required, but the binary supplied to --language is the important argument.

 dredd ./blueprint.apib http://localhost:4567 --server "./my-server" --language ./go-hook-server --hookfiles *.rb

Here is an example usage from the test cucumber/execution_order.feature, which consumes all the available callbacks. For more information on the Transaction object, see transaction.go.

package main

import (
	"fmt"
	"log"

	"github.com/snikch/goodman"
)

func main() {
	fmt.Println("Starting")
	server := goodman.NewServer(NewRunner())
	log.Fatal(server.Run())
}

// NewTestRunner creates a runner
func NewRunner() *goodman.Runner {
	runner := goodman.NewRunner()
	runner.BeforeAll(func(t []*goodman.Transaction) {
		t[0].AddTestOrderPoint("before all modification")
	})
	runner.BeforeEach(func(t *goodman.Transaction) {
		t.AddTestOrderPoint("before each modification")
	})
	runner.Before("/message > GET", func(t *goodman.Transaction) {
		t.AddTestOrderPoint("before modification")
	})
	runner.BeforeEachValidation(func(t *goodman.Transaction) {
		t.AddTestOrderPoint("before each validation modification")
	})
	runner.BeforeValidation("/message > GET", func(t *goodman.Transaction) {
		t.AddTestOrderPoint("before validation modification")
	})
	runner.After("/message > GET", func(t *goodman.Transaction) {
		t.AddTestOrderPoint("after modification")
	})
	runner.AfterEach(func(t *goodman.Transaction) {
		t.AddTestOrderPoint("after each modification")
	})
	runner.AfterAll(func(t []*goodman.Transaction) {
		t[0].AddTestOrderPoint("after all modification")
	})
	return runner
}

goodman's People

Contributors

honzajavorek avatar snikch avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

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.