testutils

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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")
)

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

Types

This section is empty.

Jump to

Keyboard shortcuts

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