testutils

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package testutils provides utilities for testing SEVEN projects

Index

Constants

This section is empty.

Variables

View Source
var (

	// ProjectRoot is the root directory of this project
	ProjectRoot = filepath.Join(filepath.Dir(thisFile), "../..")

	// TestdataPath points to where testdata for the entirety of the SEVEN project is stored
	TestdataPath = path.Join(ProjectRoot, testdataFolder)
	// ExampleProjectsPath points to where example projects are stored
	ExampleProjectsPath = path.Join(ProjectRoot, testdataFolder, "example-projects")
)
View Source
var (
	// SandboxPath is the absolute path to the test sandbox directory
	SandboxPath = path.Join(ProjectRoot, testFolder, "sandbox")
)

Functions

func CheckErr

func CheckErr(t *testing.T, err error, expErr error) (endTest bool)

CheckErr checks if the given error matches the expected error. If the expected error is nil, it checks that the error is nil. It returns a flag indicating whether the test should end after this check.

func CompareJSON

func CompareJSON(b1, b2 []byte) (areEqual bool, err error)

CompareJSON parses two byte strings as JSON and compares them.

func Diff

func Diff(str1, str2 string) (diffExists bool)

Diff compares two multi-line strings and prints a Diff similar to `git Diff`. It returns true if the strings are equal, false otherwise.

func MustReadFile

func MustReadFile(t *testing.T, filePath string) []byte

MustReadFile reads the file at the given path into memory and returns its contents as a byte slice. If there is an error reading the file, it fails the test.

func Ptr

func Ptr[T any](v T) *T

func UseSandbox

func UseSandbox(t *testing.T)

UseSandbox will temporarily change the working directory to the sandbox for testing and cleanup and reset the working directory when the test finishes

Types

This section is empty.

Jump to

Keyboard shortcuts

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