fileblock

package
v0.37.13 Latest Latest
Warning

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

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

Documentation

Overview

Package fileblock implements evaluation of file assertions parsed from rehearse scenario `### Assert: file` headings. Each evaluation function is a pure function (no global state, no side effects beyond reading the filesystem) that returns (passed bool, message string).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Eval

func Eval(fa scenario.FileAssertion, workDir string) (bool, string)

Eval is the dispatcher: it resolves the path (relative paths are joined to workDir; absolute paths are used as-is) and delegates to the appropriate evaluation function based on fa.Kind. If the path contains glob characters (*?[), it expands the glob and applies set-based logic to all matched files.

func EvalContains

func EvalContains(path, expected string) (bool, string)

EvalContains returns (true, "") when the file at path contains the expected substring, or (false, message) when it does not. Returns (false, message) when the file cannot be read.

func EvalExists

func EvalExists(path string) (bool, string)

EvalExists returns (true, "") when path exists on the filesystem, or (false, message) when it does not.

func EvalMissing

func EvalMissing(path string) (bool, string)

EvalMissing is the inverse of EvalExists: returns (true, "") when path is absent, or (false, message) when the file exists.

func EvalNotContains

func EvalNotContains(path, expected string) (bool, string)

EvalNotContains is the inverse of EvalContains: returns (true, "") when the file does not contain the substring, or (false, message) when it does. Returns (false, message) when the file cannot be read.

func EvalPermissions

func EvalPermissions(path, expected string) (bool, string)

EvalPermissions returns (true, "") when the file's permission bits match the expected octal string (e.g. "0644"), or (false, message) when they differ. Returns (false, message) when the file cannot be stat'd.

Types

This section is empty.

Jump to

Keyboard shortcuts

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