testCommon

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2018 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const DotnetExampleFullImageName = DotnetExampleTargetRegistryName + "/" + DotnetExampleTargetImageName

DotnetExampleFullImageName is the image name for dotnet example

View Source
const DotnetExampleTargetImageName = "img"

DotnetExampleTargetImageName is a placeholder image name

View Source
const DotnetExampleTargetRegistryName = "registry"

DotnetExampleTargetRegistryName is a placeholder registry name

View Source
const StaticFileHost = "http://localhost" + staticFilePort

StaticFileHost is where the file server is

View Source
const TestsDockerRegistryName = "unit-tests/"

TestsDockerRegistryName is the registry name used for testing

Variables

View Source
var DotnetExampleDependencies = *NewImageDependencies(
	DotnetExampleFullImageName,
	"microsoft/aspnetcore:2.0.6",
	[]string{"microsoft/aspnetcore-build:2.0", "imaginary/cert-generator:1.0"},
)

DotnetExampleDependencies links to the project in ${workspaceRoot}/tests/resources/docker-dotnet

View Source
var DotnetExampleMinimalBuildArg = []string{"build_image=aspnetcore-build"}

DotnetExampleMinimalBuildArg is the minimal build arg required for dotnet example

View Source
var EmptyContext = build.NewContext([]build.EnvVar{}, []build.EnvVar{})

EmptyContext is an empty build context

View Source
var ExpectedACRBuilderRelativePaths = []string{
	"Dockerfile",
	"CONTRIBUTING.md",
	"Makefile",
	"main.go",
	"README.md",
	"VERSION",
	"LICENSE",
}
View Source
var ExpectedMultiStageExampleRelativePaths = []string{
	"Dockerfile",
	"program.go",
}

HelloNodeExampleDependencies returns dependencies to the project in ${workspaceRoot}/tests/resources/hello-node

View Source
var MultiStageExampleRoot string

MultiStageExampleRoot is the multistage example's root

MultistageExampleDependencies returns dependencies to the project in ${workspaceRoot}/tests/resources/hello-multistage with default docker registry name

View Source
var NilError error

NilError is a placeholder for mock objects to use when mocking a function that returns an error

Functions

func AssertErrorPattern added in v0.5.0

func AssertErrorPattern(t *testing.T, pattern string, err error)

func AssertSameDependencies

func AssertSameDependencies(t *testing.T, expectedList []build.ImageDependencies, actualList []build.ImageDependencies)

AssertSameDependencies help determine two sets of dependencies are equivalent

func AssertSameEnv

func AssertSameEnv(t *testing.T, expected, actual []build.EnvVar)

AssertSameEnv asserts two sets environment variable are the same

func DependenciesWithDigests

func DependenciesWithDigests(original build.ImageDependencies) *build.ImageDependencies

DependenciesWithDigests populates mock digest values for image dependencies

func GetDigest

func GetDigest(image string) string

GetDigest gets the mock digest of a image

func GetRepoDigests

func GetRepoDigests(image string) string

GetRepoDigests gets the mock RepoDigests of a image

func HelloNodeExampleDependenciesOn

func HelloNodeExampleDependenciesOn(registry string) build.ImageDependencies

HelloNodeExampleDependenciesOn returns dependencies to the project in ${workspaceRoot}/tests/resources/hello-node

func ImageReferenceWithDigest

func ImageReferenceWithDigest(original *build.ImageReference) *build.ImageReference

ImageReferenceWithDigest populates mock digest values for image

func MultistageExampleDependenciesOn

func MultistageExampleDependenciesOn(registry string) build.ImageDependencies

MultistageExampleDependenciesOn returns dependencies to the project in ${workspaceRoot}/tests/resources/hello-multistage

func NewImageDependencies

func NewImageDependencies(image string, runtime string, buildtimes []string) *build.ImageDependencies

NewImageDependencies creates a image dependency object

func ReportOnError

func ReportOnError(t *testing.T, f func() error)

ReportOnError Reports an error when function fails

func StartStaticFileServer

func StartStaticFileServer(t *testing.T, handler http.Handler) *http.Server

StartStaticFileServer starts a file server, if error returned is not null the caller should close it

func StreamArchiveFromDir added in v0.5.0

func StreamArchiveFromDir(t *testing.T, root string, w io.Writer) error

StreamArchiveFromDir takes a directory and create a tar.gz out of it

Types

type FixedResponseHandler added in v0.5.0

type FixedResponseHandler struct {
	Body         []byte
	ErrorMessage string
	StatusCode   int
}

FixedResponseHandler serves a fix response

func (*FixedResponseHandler) ServeHTTP added in v0.5.0

func (h *FixedResponseHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type MappedStringGenerator

type MappedStringGenerator struct {
	StringGenerator
	// contains filtered or unexported fields
}

MappedStringGenerator geneate unique strings and allow lookup for string that was generated

func NewMappedGenerator

func NewMappedGenerator(prefix string) *MappedStringGenerator

NewMappedGenerator generates a unique string and can be looked up later by the given key value

func (*MappedStringGenerator) Lookup

func (g *MappedStringGenerator) Lookup(key string) string

Lookup the unique string generated

func (*MappedStringGenerator) NextWithKey

func (g *MappedStringGenerator) NextWithKey(key string) string

NextWithKey generates a unique string and can be looked up later by the given key value

type StaticArchiveHandler

type StaticArchiveHandler struct {
	T           *testing.T
	ArchiveRoot string
}

StaticArchiveHandler streams the hello-multistage project to http response as tar.gz We hard code the archive file for now, because we only have 1 test scenario using it

func (*StaticArchiveHandler) ServeHTTP

func (h *StaticArchiveHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP serves content of a directory

type StaticContentHandler

type StaticContentHandler struct {
	T       *testing.T
	Content []byte
}

StaticContentHandler serves a fixed string

func (*StaticContentHandler) ServeHTTP

func (h *StaticContentHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP serves the static contents

type StringGenerator

type StringGenerator struct {
	Prefix string
	// contains filtered or unexported fields
}

StringGenerator generate unique string with given prefix

func (*StringGenerator) Next

func (g *StringGenerator) Next() string

Next get next unique value

type TestConfig

type TestConfig struct {
	ProjectRoot string
}

TestConfig is the configuration used for unit tests

var Config TestConfig

Config is the instance of test config object loaded form default locations

Jump to

Keyboard shortcuts

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