metadata

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 29, 2018 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package metadata provides a struct for storing browser metadata.

Index

Constants

View Source
const (
	RecordNever  = "never"
	RecordFailed = "failed"
	RecordAlways = "always"
)

Values for Metadata.RecordVideo.

Variables

This section is empty.

Functions

This section is empty.

Types

type Extension

type Extension interface {
	// Merge merges this extension data with another set of Extension data. It should not mutate either
	// Extension object, but it is allowed to return one of the Extension objects unchanged if needed.
	// In general values in other should take precedence over values in this object.
	Merge(other Extension) (Extension, error)
	// Normalize normalizes and validate the extension data.
	Normalize() error
}

Extension is an interface for adding additional fields that will be parsed as part of the metadata.

type Metadata

type Metadata struct {
	// The Capabilities that should be used for this browser.
	Capabilities map[string]interface{} `json:"capabilities,omitempty"`
	// The Environment that web test launcher should use to to launch the browser.
	Environment string `json:"environment,omitempty"`
	// Label for the web_test rule.
	Label string `json:"label,omitempty"`
	// Browser label set in the web_test rule.
	BrowserLabel string `json:"browserLabel,omitempty"`
	// Test label set in the web_test rule.
	TestLabel string `json:"testLabel,omitempty"`
	// Config label set in the web_test rule.
	ConfigLabel string `json:"configLabel,omitempty"`
	// Port to connect debugger to. If 0, debugger will not be started.
	DebuggerPort int `json:"debuggerPort,omitempty"`
	// A list of WebTestFiles with named files in them.
	WebTestFiles []*WebTestFiles `json:"webTestFiles,omitempty"`
	// An object for any additional metadata fields on this object.
	Extension `json:"extension,omitempty"`
}

Metadata provides necessary metadata for launching a browser.

func FromBytes

func FromBytes(bytes []byte, ext Extension) (*Metadata, error)

FromBytes reads a Metadata object from a byte array.

func FromFile

func FromFile(filename string, ext Extension) (*Metadata, error)

FromFile reads a Metadata object from a json file.

func Merge

func Merge(m1, m2 *Metadata) (*Metadata, error)

Merge takes two Metadata objects and merges them into a new Metadata object.

func (*Metadata) GetFilePath

func (m *Metadata) GetFilePath(name string) (string, error)

GetFilePath returns the path to a file specified by web_test_archive, web_test_named_executable, or web_test_named_file.

func (*Metadata) Resolver

func (m *Metadata) Resolver() capabilities.Resolver

Resolver returns a Resolver that processes ENV, FILE, and METADATA prefixed capabilities variables.

func (*Metadata) ToBytes

func (m *Metadata) ToBytes() ([]byte, error)

ToBytes serializes metadata.

func (*Metadata) ToFile

func (m *Metadata) ToFile(filename string) error

ToFile writes m to filename as json.

type WebTestFiles

type WebTestFiles struct {
	// ArchiveFile is optional path to an archive file (.zip, .tar.gz, .tgz, .tar.bz2, .tbz2, .tar.Z)
	// file. If present, paths in NamedFiles are paths in the archive. If absent, paths in NamedFiles
	// are relative to the runfiles root. The archive will only be extracted if getFilePath is called
	// at least once with a name defined in NamedFiles. If so, the entire archive will be extracted
	// into subdirectory located test tmpdir.
	ArchiveFile string `json:"archiveFile,omitempty"`
	// StripPrefix is an optional prefix that will be stripped when an archive is extracted.
	StripPrefix string `json:"stripPrefix,omitempty"`
	// NamedFiles is a map of names to file paths. These file paths are relative to the runfiles
	// root if ArchiveFile is absent, otherwise they are paths inside the archive referred to by
	// ArchiveFile. The names are used by other parts of Web Test Launcher to refer to needed
	// resources. For example, if your environment needs to know where a chromedriver executable is
	// located, then there could be a name "CHROMEDRIVER" that refers to the path to the chromedriver
	// executable, and the part of you environment that needs to use the chromedriver executable
	// can call md.GetFilePath("CHROMEDRIVER") (where md is a *metadata.Metadata object) which will
	// search through all NamedFiles of all WebTestFiles structs in md to find that key and return
	// the path to the corresponding file (extracting an archive if necessary).
	NamedFiles map[string]string `json:"namedFiles"`
	// contains filtered or unexported fields
}

WebTestFiles defines a set of namedFiles located either in the runfiles directory or in an archive file located in the runfiles directory of the test.

Directories

Path Synopsis
Package capabilities performs operations on maps representing WebDriver capabilities.
Package capabilities performs operations on maps representing WebDriver capabilities.
Binary merger takes multiple metadata files and merges them to produce a single metadata file.
Binary merger takes multiple metadata files and merges them to produce a single metadata file.

Jump to

Keyboard shortcuts

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