proj

package
v0.48.2 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package proj contains test utilities for dealing with project paths and the like. The sq project dir is accessed via the Dir function. When proj's init function returns, certain envars such as SQ_ROOT are guaranteed to be set. Thus the following will work as expected:

p := proj.Expand("${SQ_ROOT}/go.mod")

Index

Constants

View Source
const (
	// EnvRoot is the name of the envar holding the path of
	// the sq project root.
	EnvRoot = "SQ_ROOT"

	// EnvPassw is the name of the envar holding the standard
	// password used for testing.
	EnvPassw = "SQ_PASSW"

	// DefaultPassw is the default password used for testing.
	DefaultPassw = "p_ssW0rd"

	EnvLogFile = "SQ_LOGFILE"
)

Variables

This section is empty.

Functions

func Abs

func Abs(projRelPath string) string

Abs returns the absolute path of projRelPath, where projRelPath is relative to the project dir.

func BoolEnvar

func BoolEnvar(envar string) bool

BoolEnvar returns true if the environment variable e is set and its value is boolean true.

func Dir

func Dir() string

Dir returns the absolute path to the root of the sq project, as set in envar EnvRoot or determined programmatically.

func Expand

func Expand(s string) string

Expand wraps os.ExpandEnv. This function is preferred as it ensures that envar SQ_ROOT is set (via proj's init function).

func LogFile

func LogFile() string

LogFile returns the path to sq's log file, as specified by EnvLogFile. If none set, the empty string is returned.

func Passw

func Passw() string

Passw returns the password used for testing.

func ReadFile

func ReadFile(projRelPath string) []byte

ReadFile is a convenience function for reading a file under the proj dir. It's equivalent to os.ReadFile(proj.Abs(path)) but panics on any error.

func Rel

func Rel(path string) string

Rel returns the relative path from the current working dir to path, where path is relative to the project dir. This is useful for accessing common test fixtures across packages.

Types

This section is empty.

Jump to

Keyboard shortcuts

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