test

package
v0.11.4 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2023 License: MPL-2.0 Imports: 13 Imported by: 0

README

Waypoint End-to-End Testing

Requirements

For now, these tests assume that you already have Waypoint available on the path, as well as Docker, K8s, and Nomad installed and running. In the future, the run-tests.sh script will set these up in a CI environment.

How to run

The easiest way to run these tests is to use the shell runner with ./run-tests.sh.

If you wish to run the script outside of this test directory, the following environment variable must be set so that it knows where the test-e2e directory is at:

  • WP_TESTE2E_DIR (string) - Path to test-e2e.

For example, running these tests from the Waypoint root directory:

WP_TESTE2E_DIR="test-e2e" ./test-e2e/run-tests.sh

How to write a new test

Create a new Go test file that has a relevant description for what the test will be. For example, if you wanted to test and end-to-end scenario with Nomad, you might call it nomad_smoke_test.go. The run-tests.sh script will pick up and run this test file by defailt with go test .. But if you wish to run it yourself without the shell runner, you can execute the test with go test <filename> util.go. You need to include util.go to get the helper functions for running the tests.

A simple test might be seeing that the Waypoint command line tool is available:

package test

import (
	"strings"
	"testing"
)

func TestWaypointAvailable(t *testing.T) {
	wp := NewBinary(wpBinary, ".")
	stdout, stderr, err := wp.Run("version")
	if err != nil {
		t.Errorf("unexpected error getting version: %s", err)
	}

	if stderr != "" {
		t.Errorf("unexpected stderr output getting version: %s", stderr)
	}

	if !strings.Contains(stdout, "Waypoint v") {
		t.Errorf("No version output detected:\n%s", stdout)
	}
}

The util.go file inside this directory offers a simple way to execute any binary.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Getenv

func Getenv(key, def string) string

Obtains the env var key. If unset, it returns the default

func NewBinary

func NewBinary(t *testing.T, binaryPath string, workingDir string) *binary

func SetupTestProject added in v0.7.0

func SetupTestProject(templateDir string) (projectName string, projectDir string, err error)

Sets up a new project test directory in a temp folder, and renames the project to have a random suffix. Provides project isolation between runs.

func TestWaypointInstall

func TestWaypointInstall(t *testing.T)

Types

type TableOutput added in v0.7.0

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

Super minimal table representation

Jump to

Keyboard shortcuts

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