extracttest

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2024 License: Apache-2.0 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 InventoryCmpLess

func InventoryCmpLess(a, b *extractor.Inventory) bool

InventoryCmpLess is a comparator function for Inventories, to be used in tests with cmp.Diff to disregard the order in which the Inventories 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
	WantInventory []*extractor.Inventory
	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