ventures

package
v0.0.0-...-4670381 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2020 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package ventures collects together the handling of all Venture specific requests. Functionality in this package is primarily tested using API tests within the /tests directory of this project.

A Venture is an abstract concept synonymous with projects. The word was selected as a comprimise between the strict professional perpective of work & business and the powerful effectiveness of stories and exploration on informal learning, problem solving, and decision making.

The ability to explore and experiment is often missing or with held from individuals and teams, yet, it's essential to their success and progression. By connecting the sense of adventure and positive feelings it invokes, individuals and teams are able to optimise themselves for their environments which almost always results in a significant increase in it performance, happiness, and active engagement.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertEqualsModified

func AssertEqualsModified(t *testing.T, before *Venture, after *Venture)

AssertEqualsModified asserts that the before Venture equals the after Venture except for the 'LastModified' field which must be greater then the after Venture.

func AssertGenericReplyFromReader

func AssertGenericReplyFromReader(t *testing.T, r io.Reader)

AssertGenericReplyFromReader asserts that reading from an io.Reader produces a generic reply.

func AssertGenericVenture

func AssertGenericVenture(t *testing.T, v Venture)

AssertGenericVenture asserts that a Venture has the required fields populated and in the correct format

func AssertGenericVentureSlice

func AssertGenericVentureSlice(t *testing.T, vens []Venture)

AssertGenericVentureSlice asserts that a Venture slice has the required fields populated and in the correct format

func AssertOrderlessSlicesEqual

func AssertOrderlessSlicesEqual(t *testing.T, exp []Venture, act []Venture)

AssertOrderlessSlicesEqual asserts that the two slices contain the same Ventures but differences in order should be ignored

func AssertVenture

func AssertVenture(t *testing.T, v Venture)

AssertVenture asserts that a Venture 'v' has valid content.

func AssertVentureModEquals

func AssertVentureModEquals(t *testing.T, exp Venture, act Venture)

AssertVentureModEquals asserts that the two Ventures are equal with the exception of the last_modified field

func AssertVentureSlice

func AssertVentureSlice(t *testing.T, vens []Venture)

AssertVentureSlice asserts that all Ventures 'vens' have valid content.

func AssertVentureSliceModEquals

func AssertVentureSliceModEquals(t *testing.T, exp map[string]Venture, act []Venture)

AssertVentureSliceModEquals asserts that the two Venture slices are equal with the exception of the last_modified fields

func AssertVenturesEqual

func AssertVenturesEqual(t *testing.T, exp []Venture, act []Venture, orderless bool)

AssertVenturesEqual asserts that 'exp' and 'act' contain the same Ventures. If 'orderless' is true then the slices are ordered by ID first.

func CreateTables

func CreateTables() (err error)

CreateTables creates all the Venture tables, views and triggers within the supplied database.

func Handler

func Handler(res http.ResponseWriter, req *http.Request)

Handler handles requests to do with collections of, or individual, Ventures.

Types

type ByVenID

type ByVenID []Venture

ByVenID is a slice of Ventures

func (ByVenID) Len

func (bv ByVenID) Len() int

Len implements from sort.Interface

func (ByVenID) Less

func (bv ByVenID) Less(i, j int) bool

Less implements from sort.Interface

func (ByVenID) Swap

func (bv ByVenID) Swap(i, j int)

Swap implements from sort.Interface

type ModVenture

type ModVenture struct {
	IDs    string  `json:"ids"`
	Props  string  `json:"set"`
	Values Venture `json:"values"`
}

ModVenture represents an update to a Venture.

func DecodeModVenture

func DecodeModVenture(r io.Reader) (ModVenture, error)

DecodeModVenture decodes a ModVenture from data obtained via a Reader.

func (*ModVenture) ApplyMod

func (mv *ModVenture) ApplyMod(ven *Venture)

ApplyMod applies the modifications to the supplied Venture only touching those properties the user has specified

func (*ModVenture) Clean

func (mv *ModVenture) Clean()

Clean cleans up the ModVenture by removing whitespace where applicable.

func (*ModVenture) SplitIDs

func (mv *ModVenture) SplitIDs() []string

SplitIDs returns the IDs of the Ventures to update as a slice.

func (*ModVenture) SplitProps

func (mv *ModVenture) SplitProps() []string

SplitProps returns the property names of the properties to update.

func (*ModVenture) Update

func (mv *ModVenture) Update() ([]Venture, bool)

Update pushes the modification of changes to the database.

func (*ModVenture) Validate

func (mv *ModVenture) Validate() []string

Validate checks each field contains valid content returning a non-empty slice of human readable error messages detailing the violations found or an empty slice if all is well. These messages are suitable for returning to clients.

type NewVenture

type NewVenture struct {
	Description string `json:"description"`
	Orders      string `json:"orders"`
	State       string `json:"state"`
	Extra       string `json:"extra"`
}

NewVenture represents a new Venture.

func DecodeNewVenture

func DecodeNewVenture(r io.Reader) (NewVenture, error)

DecodeNewVenture decodes a NewVenture from data obtained via a Reader

func (*NewVenture) Clean

func (nv *NewVenture) Clean()

Clean removes redundent whitespace from property values within a Venture except where whitespace is allowable.

func (*NewVenture) Insert

func (nv *NewVenture) Insert() (ven *Venture, ok bool)

Insert inserts the NewVenture into the database

func (*NewVenture) Validate

func (nv *NewVenture) Validate() []string

Validate checks each field contains valid content returning a non-empty slice of human readable error messages detailing the violations found or an empty slice if all is well. These messages are suitable for returning to clients.

type Venture

type Venture struct {
	ID           string `json:"id,omitempty"`
	LastModified int64  `json:"last_modified"`
	Description  string `json:"description"`
	Orders       string `json:"orders,omitempty"`
	State        string `json:"state"`
	Dead         bool   `json:"dead,omitempty"`
	Extra        string `json:"extra,omitempty"`
}

Venture represents a Venture, aka, project.

func AssertVentureFromReader

func AssertVentureFromReader(t *testing.T, r io.Reader) Venture

AssertVentureFromReader asserts that a Venture decoded from an io.Reader has the required fields populated and in the correct format

func AssertVentureSliceFromReader

func AssertVentureSliceFromReader(t *testing.T, r io.Reader) []Venture

AssertVentureSliceFromReader asserts that a Venture slice decoded from an io.Reader has the required fields populated and in the correct format

func AssertWrappedVentureFromReader

func AssertWrappedVentureFromReader(t *testing.T, r io.Reader) (wrapped.WrappedReply, Venture)

AssertWrappedVentureFromReader asserts that a Venture wrapped within a WrappedReply and decoded from an io.Reader has the required fields populated and in the correct format

func AssertWrappedVentureSliceFromReader

func AssertWrappedVentureSliceFromReader(t *testing.T, r io.Reader) (wrapped.WrappedReply, []Venture)

AssertWrappedVentureSliceFromReader asserts that a Venture slice wrapped within a WrappedReply and decoded from an io.Reader has the required fields populated and in the correct format

func DecodeVenture

func DecodeVenture(r io.Reader) (Venture, error)

DecodeVenture decodes a Venture from data obtained via a Reader.

func DecodeVentureSlice

func DecodeVentureSlice(r io.Reader) ([]Venture, error)

DecodeVentureSlice decodes a slice of Ventures from data obtained via a Reader.

func QueryAll

func QueryAll() ([]Venture, error)

QueryAll queries the database for all Ventures.

func QueryFor

func QueryFor(id string) (*Venture, error)

QueryFor queries the database for a single Venture.

func QueryMany

func QueryMany(ids []interface{}) ([]Venture, error)

QueryMany queries the database for all specified Ventures.

func RequireSliceOfVentures

func RequireSliceOfVentures(t *testing.T, r io.Reader) []Venture

RequireSliceOfVentures asserts that the value decoded from 'r' is a slice of valid Ventures; the slice is returned.

func (*Venture) Clean

func (ven *Venture) Clean()

Clean removes redundent whitespace from property values within a Venture except where whitespace is allowable.

func (*Venture) SetOrders

func (ven *Venture) SetOrders(ids []string)

SetOrders sets the Orders CSV from a slice of Order IDs.

func (*Venture) SplitOrders

func (ven *Venture) SplitOrders() []string

SplitOrders returns the IDs of the Orders as a slice.

func (*Venture) Update

func (ven *Venture) Update() error

Update updates the Venture within the database.

func (*Venture) Validate

func (ven *Venture) Validate(isNew bool) []string

Validate checks each field contains valid content returning a non-empty slice of human readable error messages detailing the violations found or an empty slice if all is well. These messages are suitable for returning to clients.

Jump to

Keyboard shortcuts

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