spec2test

package module
v0.0.0-...-784893d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 3, 2015 License: MIT Imports: 10 Imported by: 0

README

spec2test

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddResource

func AddResource(r interface{}, actionsOne, actionsMany []Action) error
Example
package main

import (
	"fmt"

	"github.com/adams-sarah/spec2test"
)

func main() {
	fmt.Println("# before:", len(spec2test.AllResourceTypes()))

	type MyType struct {
		Name string
	}

	oneActions := []spec2test.Action{
		spec2test.Create,
		spec2test.Read,
		spec2test.Update,
		spec2test.Destroy,
	}

	manyActions := []spec2test.Action{
		spec2test.Read,
	}

	err := spec2test.AddResource(MyType{"Sarah"}, oneActions, manyActions)
	if err != nil {
		// do something
	}

	fmt.Println("# after:", len(spec2test.AllResourceTypes()))

}
Output:

# before: 0
# after: 1

func AllResourceTypes

func AllResourceTypes() []reflect.Type

func Decode

func Decode(contentType string, src io.Reader, dest interface{}) error

func Encode

func Encode(contentType string, v interface{}, w io.Writer) error

func EndpointTestTmp

func EndpointTestTmp(t *testing.T)

func NewEmptyClone

func NewEmptyClone(obj interface{}) interface{}

func ValueDeepEqual

func ValueDeepEqual(v1, v2 interface{}) bool

Types

type Action

type Action int
const (
	Create Action = iota
	Read
	Update
	Destroy
)

type Decoder

type Decoder interface {
	Decode(v interface{}) error
}

type Encoder

type Encoder interface {
	Encode(v interface{}) error
}

type Error

type Error int
const (
	ErrorStructTypeRequired Error = iota
	ErrorResourceAlreadyAdded
	ErrorContentTypeNotSupported
)

func (Error) Error

func (err Error) Error() string

func (Error) String

func (i Error) String() string

type HTTPMethod

type HTTPMethod int
const (
	GET HTTPMethod = iota
	HEAD
	POST
	PUT
	DELETE
	TRACE
	OPTIONS
	CONNECT
	PATCH
)

type Resource

type Resource struct {
	// contains filtered or unexported fields
}

type ResourceType

type ResourceType int
const (
	One ResourceType = iota
	Many
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL