mandosjsonparse

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2020 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsStar

func IsStar(obj oj.OJsonObject) bool

Types

type DefaultFileResolver

type DefaultFileResolver struct {
	// contains filtered or unexported fields
}

DefaultFileResolver loads file contents for the test parser.

func NewDefaultFileResolver

func NewDefaultFileResolver() *DefaultFileResolver

NewDefaultFileResolver yields a new DefaultFileResolver instance.

func (*DefaultFileResolver) ReplacePath

func (fr *DefaultFileResolver) ReplacePath(pathInTest, actualPath string) *DefaultFileResolver

ReplacePath offers the possibility to swap a path with another withouot providing a new set of tests. It is very useful when testing multiple contracts against the same tests.

func (*DefaultFileResolver) ResolveAbsolutePath

func (fr *DefaultFileResolver) ResolveAbsolutePath(value string) string

ResolveAbsolutePath yields absolute value based on context.

func (*DefaultFileResolver) ResolveFileValue

func (fr *DefaultFileResolver) ResolveFileValue(value string) ([]byte, error)

ResolveFileValue converts a value prefixed with "file:" and replaces it with the file contents.

func (*DefaultFileResolver) SetContext

func (fr *DefaultFileResolver) SetContext(contextPath string)

SetContext sets directory where the test runs, to help resolve relative paths.

type FileResolver

type FileResolver interface {
	// SetContext sets directory where the test runs, to help resolve relative paths.
	SetContext(contextPath string)

	// ResolveAbsolutePath yields absolute value based on context.
	ResolveAbsolutePath(value string) string

	// ResolveFileValue converts a value prefixed with "file:" and replaces it with the file contents.
	ResolveFileValue(value string) ([]byte, error)
}

FileResolver resolves values starting with "file:"

type Parser

type Parser struct {
	FileResolver FileResolver
}

Parser performs parsing of both json tests (older) and scenarios (new).

func (*Parser) ParseScenarioFile

func (p *Parser) ParseScenarioFile(jsonString []byte) (*mj.Scenario, error)

ParseScenarioFile converts a scenario json string to scenario object representation

func (*Parser) ParseScenarioStep

func (p *Parser) ParseScenarioStep(jsonSnippet string) (mj.Step, error)

ParseScenarioStep parses a single scenario step, instead of an entire file. Handy for tests, where step snippets can be embedded in code.

func (*Parser) ParseTestFile

func (p *Parser) ParseTestFile(jsonString []byte) ([]*mj.Test, error)

ParseTestFile converts json string to object representation

Jump to

Keyboard shortcuts

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