testerator

package module
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2020 License: MIT Imports: 7 Imported by: 0

README

testerator

testerator is TEST execution accelERATOR for GoogleAppEngine/Go starndard environment.

see GoDoc.

TODO

  • write document about ResetThreshold.

Documentation

Overview

Package testerator is TEST execution accelERATOR for GoogleAppEngine/Go starndard environment.

When you call the `aetest.NewInstance`, dev_appserver.py will spinup every time. This is very high cost operation. Testerator compress the time of dev_appserver.py operation.

following code launch dev server. It's slow (~4s).

opt := &aetest.Options{AppID: "unittest", StronglyConsistentDatastore: true}
inst, err := aetest.NewInstance(opt)

testerator wrapped devserver spinup. for example.

func TestMain(m *testing.M) {
	_, _, err := testerator.SpinUp()
	if err != nil {
		fmt.Printf(err.Error())
		os.Exit(1)
	}

	status := m.Run()

	err = testerator.SpinDown()
	if err != nil {
		fmt.Printf(err.Error())
		os.Exit(1)
	}

	os.Exit(status)
}

func TestFooBar(t *testing.T) {
	_, c, err := testerator.SpinUp()
	if err != nil {
		t.Fatal(err.Error())
	}
	defer testerator.SpinDown()

	// write some test!
}

If you want to clean up Datastore or Search API or Memcache, You should import above packages.

import (
	// do testerator feature setup
	_ "github.com/favclip/testerator/datastore"
	_ "github.com/favclip/testerator/search"
	_ "github.com/favclip/testerator/memcache"
)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsCI

func IsCI() bool

IsCI returns this execution environment is Continuous Integration server or not. Deprecated.

func SpinDown

func SpinDown() error

SpinDown dispatch spin down request to DefaultSetup.SpinDown.

func SpinUp

func SpinUp() (aetest.Instance, context.Context, error)

SpinUp dispatch spin up request to DefaultSetup.SpinUp.

Types

type Helper

type Helper func(s *Setup) error

Helper uses for setup hooks to Setup struct.

type Setup

type Setup struct {
	Instance      aetest.Instance
	Disable1stGen bool
	RaisePanic    bool
	Options       *aetest.Options
	Context       context.Context

	Setuppers []Helper
	Cleaners  []Helper

	ResetThreshold int
	SpinDowns      []chan struct{}

	sync.Mutex
	// contains filtered or unexported fields
}

Setup contains aetest.Instance and other environment for setup and clean up.

var DefaultSetup *Setup

DefaultSetup uses from bare functions.

func (*Setup) AppendCleanup added in v1.3.0

func (s *Setup) AppendCleanup(h Helper)

func (*Setup) AppendSetuppers added in v1.3.0

func (s *Setup) AppendSetuppers(h Helper)

func (*Setup) SpinDown

func (s *Setup) SpinDown() error

SpinDown dev server.

This function clean up dev server environment. call each DefaultSetup.Cleaners. usually, it means cleanup Datastore and Search APIs and miscs. see document for SpinUp function.

func (*Setup) SpinUp

func (s *Setup) SpinUp() error

SpinUp dev server.

If you call this function twice. launch dev server and increment internal counter twice. 1st time then dev server is up and increment internal counter. 2nd time then dev server is increment internal counter only. see document for SpinDown function.

Directories

Path Synopsis
aeinternal
search
Package search is a generated protocol buffer package.
Package search is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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