utils

package
v0.0.161 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2025 License: 0BSD Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DirectoryField        = "directory"
	SizeInBytesField      = "size_in_bytes"
	FolderToFindField     = "folder_to_find"
	InitialDirField       = "initial_directory"
	HostField             = "host"
	CurrentAttemptField   = "current_attempt"
	MaximumAttemptsFields = "maximum_attempts"
	PortField             = "port"
)

Variables

View Source
var (
	Logger               = deepstack.NewDeepStackLogger(slog.LevelInfo)
	OperationFailedError = "Operation failed"
)

Functions

func AnalyzeCode added in v0.0.56

func AnalyzeCode(tr *taskrunner.TaskRunner, dir string)

func AssertDeepStackErrorFromRequest added in v0.0.132

func AssertDeepStackErrorFromRequest(t *testing.T, err error, expectedResponseBodyErrorMessage string)

func AssertInvalidInputError added in v0.0.156

func AssertInvalidInputError(t *testing.T, err error)

func BuildWholeGoProject added in v0.0.131

func BuildWholeGoProject(Tr *taskrunner.TaskRunner, directory string)

BuildWholeGoProject this function is meant to detect compile errors in the test code with build tags

func Close added in v0.0.55

func Close(r Closable)

func CollectBuildTags added in v0.0.68

func CollectBuildTags(dir string) ([]string, error)

func DoesMatchSaltedHash added in v0.0.45

func DoesMatchSaltedHash(clearText, saltedHash string) bool

func ExtractError added in v0.0.160

func ExtractError(err error) string

func FindDir added in v0.0.49

func FindDir(dirName string) (string, error)

func GenerateCookie added in v0.0.22

func GenerateCookie() (*http.Cookie, error)

func GenerateSecret added in v0.0.126

func GenerateSecret() (string, error)

func GetSHA256Hash added in v0.0.116

func GetSHA256Hash(plainText string) string

func GetTimeInSevenDays added in v0.0.93

func GetTimeInSevenDays() time.Time

func MapOf added in v0.0.130

func MapOf(elements ...string) map[string]any

func NewFileHandler added in v0.0.128

func NewFileHandler(level slog.Level) *slog.JSONHandler

func RemoveDir added in v0.0.57

func RemoveDir(path string)

func RunMigrations added in v0.0.50

func RunMigrations(migrationsDir, host, port string) error

func SaltAndHash added in v0.0.23

func SaltAndHash(clearText string) (string, error)

func SendJsonResponse

func SendJsonResponse(w http.ResponseWriter, data any)

func SetCookieHeaders added in v0.0.35

func SetCookieHeaders(req *http.Request, c *ComponentClient)

func UnpackResponse added in v0.0.32

func UnpackResponse[T any](object any) (*T, error)

func UpdateAlpineVersion added in v0.0.144

func UpdateAlpineVersion(dockerfilePath string) error

func WaitForPostgresDb added in v0.0.51

func WaitForPostgresDb(host, port string) (*sql.DB, error)

func WriteResponseError added in v0.0.130

func WriteResponseError(w http.ResponseWriter, expectedErrors map[string]any, err error, context ...any)

TODO errors beginning with "invalid input" always count as expected errors

Types

type Closable added in v0.0.55

type Closable interface {
	Close() error
}

type ComponentClient

type ComponentClient struct {
	Cookie            *http.Cookie
	SetCookieHeader   bool
	RootUrl           string
	Origin            string
	VerifyCertificate bool
}

func (*ComponentClient) DoRequest

func (c *ComponentClient) DoRequest(path string, payload any) ([]byte, error)

func (*ComponentClient) DoRequestWithFullResponse

func (c *ComponentClient) DoRequestWithFullResponse(path string, payload any) (*http.Response, error)

type EmailClient added in v0.0.150

type EmailClient interface {
	SendEmail(emailConfig *EmailConfig, to, body string) error
	CheckEmailServerConnection(emailConfig *EmailConfig) error
}

type EmailClientImpl added in v0.0.150

type EmailClientImpl struct{}

func (*EmailClientImpl) CheckEmailServerConnection added in v0.0.150

func (e *EmailClientImpl) CheckEmailServerConnection(emailConfig *EmailConfig) error

func (*EmailClientImpl) SendEmail added in v0.0.150

func (e *EmailClientImpl) SendEmail(emailConfig *EmailConfig, to, body string) error

type EmailClientMock added in v0.0.150

type EmailClientMock struct{}

func (EmailClientMock) CheckEmailServerConnection added in v0.0.150

func (e EmailClientMock) CheckEmailServerConnection(emailConfig *EmailConfig) error

func (EmailClientMock) SendEmail added in v0.0.150

func (e EmailClientMock) SendEmail(emailConfig *EmailConfig, to, body string) error

type EmailConfig added in v0.0.150

type EmailConfig struct {
	SMTPHost             string `validate:"host"`
	SMTPPort             string `validate:"number"`
	EmailAddress         string `validate:"email"`
	EmailAccountUsername string `validate:"user_name"`
	EmailAccountPassword string `validate:"password"`
}

type Zipper added in v0.0.158

type Zipper interface {
	ZipDirectoryWithChecks(dirPath string) ([]byte, error)
	UnzipToTempDir(zipBytes []byte) (string, error)
	ZipDirectoryWithoutChecks(dirPath string) ([]byte, error)
}

type ZipperImpl added in v0.0.158

type ZipperImpl struct{}

func (*ZipperImpl) UnzipToTempDir added in v0.0.158

func (*ZipperImpl) UnzipToTempDir(zipBytes []byte) (string, error)

UnzipToTempDir unzips the given zip bytes to a temporary directory and returns the path to the directory.

func (*ZipperImpl) ZipDirectoryWithChecks added in v0.0.158

func (*ZipperImpl) ZipDirectoryWithChecks(dirPath string) ([]byte, error)

func (*ZipperImpl) ZipDirectoryWithoutChecks added in v0.0.158

func (*ZipperImpl) ZipDirectoryWithoutChecks(dirPath string) ([]byte, error)

Jump to

Keyboard shortcuts

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