data

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package data provides access to loading and saving CTS data.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Load

func Load(dir string, vars map[string]string) (Fixtures, TestSuites, error)

Load parses JSON-encoded fixtures and test suites from the given directory (recursively).

func SaveFixture

func SaveFixture(fixture Fixture, file string) error

SaveFixture writes the JSON encoding of the fixture to the given file.

func SaveFixtures

func SaveFixtures(fixtures Fixtures, dir string) error

SaveFixtures writes the JSON encoding of fixtures to the given directory.

func SaveTestSuite

func SaveTestSuite(ts TestSuite, file string, vars map[string]string) error

SaveTestSuite writes the JSON encoding of the test suite to the given file.

func SaveTestSuites

func SaveTestSuites(tss TestSuites, dir string, vars map[string]string) error

SaveTestSuites writes the JSON encoding of test suites to the given directory.

Types

type Fixture

type Fixture []*wirebson.Document

Fixture represents a set of documents in a single collection.

func LoadFixture

func LoadFixture(file string) (Fixture, error)

LoadFixture parses a JSON-encoded fixture from the given file.

type Fixtures

type Fixtures map[string]Fixture

Fixtures is an unordered set of collection names and their documents.

func LoadFixtures

func LoadFixtures(dir string) (Fixtures, error)

LoadFixtures parses JSON-encoded fixtures from the given directory.

type TestCase

type TestCase struct {
	Request  *wirebson.Document `json:"request"`
	Response *wirebson.Document `json:"response"`
}

TestCase represents a single request / expected response pair.

type TestSuite

type TestSuite map[string]TestCase

TestSuite is an ordered set of named test cases. They are sorted by their names. Test cases may depend on previous ones.

func LoadTestSuite

func LoadTestSuite(file string, vars map[string]string) (TestSuite, error)

LoadTestSuite parses a JSON-encoded test suite from the given file.

type TestSuites

type TestSuites map[string]TestSuite

TestSuites is an unordered set of named suites. They should be independent from each other.

func LoadTestSuites

func LoadTestSuites(dir string, vars map[string]string) (TestSuites, error)

LoadTestSuites parses JSON-encoded test suites from the given directory (recursively).

Jump to

Keyboard shortcuts

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