resolvetest

package
v0.0.0-...-69d9307 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package resolvetest provides a way to define test data for resolvers.

Test data follows a simple format that describes universes (entire package ecosystems), resolved graphs, and test cases.

Below is the definition of two universes, one named sample, the other
named other, specified as a graph/schema definition.

-- Universe sample
alice
	1.0.0
		bob@1
bob
	1.0.0
	2.0.0
-- END

-- Universe other
eve
	1.0.0
		bob@1
-- END

Below is the definition of a test. It links a universe, a resolve root, a
graph for the expected resolution, and optionally sets flags.

-- Test alice
Resolve alice 1.0.0
Universe sample
Graph alice
Flag flag1 flag2
-- END

Below is the definition of a resolve.Graph, named alice, specified as a
graph/schema definition.
-- Graph alice
alice 1.0.0
└─ bob@1 1.0.0
-- END

Below is the definition of a test. It links two universes, a resolve root, a
graph for the expected resolution, and optionally sets flags. The first
universe, other, has no ID and is the default universe. The second has an
ID that is typically used in version attributes to refer to a registry.

-- Test eve
Resolve eve 1.0.0
Universe other, id_sample:sample
Graph eve
Flag flag1 flag2
-- END

Below is the definition of a resolve.Graph, named alice2, specified as a
prototext message.
alice 1.0.0
└─ bob@1 1.0.0
-- Graph prototext alice2
node: {
	version: {
		system: NPM
		package_name: "alice"
		version_type: CONCRETE
		version: "1.0.0"
	}
}
node: {
	version: {
		system: NPM
		package_name: "bob"
		version_type: CONCRETE
		version: "1.0.0"
	}
}
edge: {
	to: 1
	requirement: "1"
}
-- END

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Artifact

type Artifact struct {
	// Universe holds the defined universes, indexed by name.
	Universe map[string]*resolve.LocalClient
	// Graph holds the defined resolved graphs, indexed by name.
	Graph map[string]*resolve.Graph
	// Test holds the defined tests in the order in which they were defined.
	Test []*Test
}

Artifact describes the parsed content from a test data file.

func Parse

func Parse(r io.Reader, sys resolve.System) (*Artifact, error)

Parse parses the data from the given reader and creates for the given system test artifacts: universes, resolved graphs, and tests.

func ParseFiles

func ParseFiles(sys resolve.System, files ...string) (*Artifact, error)

ParseFiles parses the data from the given files and creates for the given system test artifacts: universes, resolved graphs, and tests.

type Test

type Test struct {
	// Name of the name of the test.
	Name string
	// VK holds the concrete version from the universe to resolve.
	VK resolve.VersionKey
	// Universe holds the universe to use for resolution.
	Universe *resolve.LocalClient
	// Graph holds the resolved graph.
	Graph *resolve.Graph
	// GraphName holds the resolved graph name.
	GraphName string
	// Flags holds the defined flags
	Flags map[string]bool
}

Test describes a parsed test.

Jump to

Keyboard shortcuts

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