extracttest

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2025 License: Apache-2.0, BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Overview

Package extracttest provides structures to help create tabular tests for extractors.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseTestScanInput

func CloseTestScanInput(t *testing.T, si filesystem.ScanInput)

CloseTestScanInput takes a scan input generated by GenerateScanInputMock and closes the associated file handle

func GenerateScanInputMock

func GenerateScanInputMock(t *testing.T, config ScanInputMockConfig) filesystem.ScanInput

GenerateScanInputMock will try to open the file locally, and fail if the file doesn't exist

func PackageCmpLess added in v0.2.0

func PackageCmpLess(a, b *extractor.Package) bool

PackageCmpLess is a comparator function for Packages, to be used in tests with cmp.Diff to disregard the order in which the Packages are reported.

Types

type ContainsErrStr

type ContainsErrStr struct {
	Str string
}

ContainsErrStr is an error that matches other errors that contains `str` in their error string.

func (ContainsErrStr) Error

func (e ContainsErrStr) Error() string

Error returns the error string

func (ContainsErrStr) Is

func (e ContainsErrStr) Is(err error) bool

Is checks whether the input error contains the string in ContainsErrStr

type ScanInputMockConfig

type ScanInputMockConfig struct {
	// Path of the file ScanInput will read, relative to the ScanRoot
	Path string
	// FakeScanRoot allows you to set a custom scanRoot, can be relative or absolute,
	// and will be translated to an absolute path
	FakeScanRoot string
	FakeFileInfo *fakefs.FakeFileInfo
}

ScanInputMockConfig is used to quickly configure building a mock ScanInput

type TestTableEntry

type TestTableEntry struct {
	Name         string
	InputConfig  ScanInputMockConfig
	WantPackages []*extractor.Package
	WantErr      error
}

TestTableEntry is a entry to pass to ExtractionTester

Jump to

Keyboard shortcuts

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