compliance

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2016 License: Apache-2.0 Imports: 14 Imported by: 2

Documentation

Overview

Package compliance provides the tools to validate the compliance of driver implementations and BQL behavior testing. The compliance package is built around stories. A story is a collection of graphs and a sequence of assertions against the provided data. An assertion is defined by a tuple containing a BQL, the execution status, and the expeted result table.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Assertion

type Assertion struct {
	// Requires of the assertion.
	Requires string

	// Statement contains the BQL query to assert.
	Statement string

	// WillFail indicates if the query should fail with and error.
	WillFail bool

	// MustReturn contains the table  containing the expected results provided
	// by the BQL statemnet execution.
	MustReturn []map[string]string
	// contains filtered or unexported fields
}

Assertion contains a BQL, the expecte status of the BQL query execution, and the returned results table.

func (*Assertion) OutputTable

func (a *Assertion) OutputTable(bo []string) (*table.Table, error)

OutputTable returns the expected result table for the must result table provided by the story.

type AssertionBattery added in v0.1.1

type AssertionBattery struct {
	Entries []*AssertionBatteryEntry
}

AssertionBattery contains the result of running a collection of stories.

func RunStories added in v0.1.1

func RunStories(ctx context.Context, st storage.Store, b literal.Builder, stories []*Story, chanSize int) *AssertionBattery

RunStories runs a the provided stories and returns the outcome of each of them.

type AssertionBatteryEntry added in v0.1.1

type AssertionBatteryEntry struct {
	Story   *Story
	Outcome map[string]*AssertionOutcome
	Err     error
}

AssertionBatteryEntry contains teh result of running a story.

type AssertionOutcome

type AssertionOutcome struct {
	Equal bool
	Got   *table.Table
	Want  *table.Table
}

AssertionOutcome contains the result of running one assertion of a given story.

type Graph

type Graph struct {
	// ID of the binding name to use for the graph.
	ID string

	// Facts contains the parseable tribles which define the graph.
	Facts []string
}

Graph contains the graph binding name and the list of parseable triples that define it.

type Story

type Story struct {
	// Name of the story.
	Name string

	// Sources contains the list of graphs used in the story.
	Sources []*Graph

	// Assertions that need to be validated against the provided sources.
	Assertions []*Assertion
}

Story contains the available graphs and the collection of assertions to validate.

func (*Story) Marshal

func (s *Story) Marshal() (string, error)

Marshal serializes the story into a JSON readable string.

func (*Story) Run

func (s *Story) Run(ctx context.Context, st storage.Store, b literal.Builder, chanSize int) (map[string]*AssertionOutcome, error)

Run evaluates a story. Returns if the story is true or not. It will also return an error if something wrong happen along the way. It is worth mentioning that Run does not clear any data avaiable in the provided storage.

func (*Story) Unmarshal

func (s *Story) Unmarshal(ss string) error

Unmarshal rebuilds a story from a JSON readable string.

Jump to

Keyboard shortcuts

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