Documentation
¶
Overview ¶
Package testfakes provides in-memory fakes for all CLI use-case interfaces. Import this package from cli tests to exercise run* functions without opening a real SQLite database.
Index ¶
- type FakeCheckCompatibility
- type FakeDiffDirectives
- type FakeDiffInterface
- type FakeDiffLicense
- type FakeDiffScanRuns
- type FakeDiffWalks
- type FakeExecuteWalk
- type FakeExtract
- type FakeExtractCallGraph
- type FakeExtractExample
- type FakeExtractFIPS
- type FakeExtractInterface
- type FakeExtractLicense
- type FakeFetchModule
- type FakeGenerateNotice
- type FakeGenerateSBOM
- type FakeQueryCallGraph
- func (f *FakeQueryCallGraph) AddGeneration(coord coordinate.ModuleCoordinate, pipelineVersion string, ...)
- func (f *FakeQueryCallGraph) AddRecord(coord coordinate.ModuleCoordinate, pipelineVersion string, ...)
- func (f *FakeQueryCallGraph) CallGraphHistory(ctx context.Context, coord coordinate.ModuleCoordinate, pipelineVersion string) ([]cgdomain.CallGraphRecord, error)
- func (f *FakeQueryCallGraph) FindCallees(_ context.Context, _, _ string, scope coordinate.ModuleSet, ...) ([]cgports.CallEdgeRef, error)
- func (f *FakeQueryCallGraph) FindCallers(_ context.Context, symbolID, _ string, scope coordinate.ModuleSet, ...) ([]cgports.CallEdgeRef, error)
- func (f *FakeQueryCallGraph) ForeignModulesBuilt(_ context.Context, coord coordinate.ModuleCoordinate, pipelineVersion string, ...) ([]cgdomain.ForeignModule, bool, error)
- func (f *FakeQueryCallGraph) GetCallGraphRecord(_ context.Context, coord coordinate.ModuleCoordinate, pipelineVersion string) (cgdomain.CallGraphRecord, bool, error)
- func (f *FakeQueryCallGraph) GetCallGraphRecordFrom(ctx context.Context, coord coordinate.ModuleCoordinate, pipelineVersion string, ...) (cgdomain.CallGraphRecord, bool, error)
- func (f *FakeQueryCallGraph) ListCallGraphCoordinates(_ context.Context, filter cgports.CallGraphFilter) ([]cgports.CallGraphCoordinate, error)
- func (f *FakeQueryCallGraph) ListCallGraphRecords(_ context.Context, filter cgports.CallGraphFilter) ([]cgports.CallGraphSummary, error)
- func (f *FakeQueryCallGraph) NotSearchedByCallees(context.Context, []string, string, coordinate.ModuleSet, ...) ([]cgports.UnservedCoordinate, error)
- func (f *FakeQueryCallGraph) NotSearchedByCallers(context.Context, []string, string, coordinate.ModuleSet, ...) ([]cgports.UnservedCoordinate, error)
- func (f *FakeQueryCallGraph) SetCallees(refs []cgports.CallEdgeRef)
- func (f *FakeQueryCallGraph) SetCallers(refs []cgports.CallEdgeRef)
- func (f *FakeQueryCallGraph) SetCallersFor(symbolID string, refs []cgports.CallEdgeRef)
- func (f *FakeQueryCallGraph) SetGetErr(err error)
- func (f *FakeQueryCallGraph) SetList(summaries []cgports.CallGraphSummary)
- func (f *FakeQueryCallGraph) SetTraverseCallees(edges []cgports.CallEdgeRef, nodes []string)
- func (f *FakeQueryCallGraph) SetTraverseCalleesTruncated(truncated bool)
- func (f *FakeQueryCallGraph) SetTraverseCallers(edges []cgports.CallEdgeRef, nodes []string)
- func (f *FakeQueryCallGraph) SetTraverseCallersTruncated(truncated bool)
- func (f *FakeQueryCallGraph) TraversalRequests() []cgapp.TraversalRequest
- func (f *FakeQueryCallGraph) TraverseCallees(_ context.Context, req cgapp.TraversalRequest) (cgapp.TraversalResult, error)
- func (f *FakeQueryCallGraph) TraverseCallers(_ context.Context, req cgapp.TraversalRequest) (cgapp.TraversalResult, error)
- func (f *FakeQueryCallGraph) UnservedCoordinates(_ context.Context, coords []coordinate.ModuleCoordinate, _ string) ([]cgports.UnservedCoordinate, error)
- type FakeQueryDirectives
- func (f *FakeQueryDirectives) CountScans(context.Context) (int, error)
- func (f *FakeQueryDirectives) GetScan(_ context.Context, _ string) (directivedomain.Record, bool, error)
- func (f *FakeQueryDirectives) ListScanProjects(context.Context) ([]string, bool, error)
- func (f *FakeQueryDirectives) ListScans(_ context.Context, _ string, limit, offset int) ([]directivedomain.Record, error)
- type FakeQueryExamples
- func (f *FakeQueryExamples) AddRecord(coord coordinate.ModuleCoordinate, pipelineVersion string, ...)
- func (f *FakeQueryExamples) ExampleHistory(_ context.Context, coord coordinate.ModuleCoordinate, pipelineVersion string) ([]exdomain.ExampleRecord, error)
- func (f *FakeQueryExamples) FindBySymbol(_ context.Context, _, _ string, _ coordinate.ModuleSet) ([]exports.ExampleRef, error)
- func (f *FakeQueryExamples) FindBySymbolInModule(_ context.Context, coord coordinate.ModuleCoordinate, _, _ string) ([]exports.ExampleRef, error)
- func (f *FakeQueryExamples) GetExampleRecord(_ context.Context, coord coordinate.ModuleCoordinate, pipelineVersion string) (exdomain.ExampleRecord, bool, error)
- func (f *FakeQueryExamples) ListExampleRecords(_ context.Context, filter exports.ExampleFilter) ([]exports.ExampleSummary, error)
- func (f *FakeQueryExamples) PipelinesHeld(_ context.Context, coord coordinate.ModuleCoordinate) ([]string, error)
- func (f *FakeQueryExamples) SetHistory(coord coordinate.ModuleCoordinate, pipelineVersion string, ...)
- func (f *FakeQueryExamples) SetList(sums []exports.ExampleSummary)
- func (f *FakeQueryExamples) SetRefs(refs []exports.ExampleRef)
- type FakeQueryExtraction
- func (f *FakeQueryExtraction) AddRun(run extractdomain.ExtractionRun)
- func (f *FakeQueryExtraction) GetExtractionRun(_ context.Context, id string) (extractdomain.ExtractionRun, error)
- func (f *FakeQueryExtraction) ListExtractionRuns(_ context.Context, filter extractports.ExtractionRunFilter) ([]extractports.ExtractionRunSummary, error)
- func (f *FakeQueryExtraction) SetList(sums []extractports.ExtractionRunSummary)
- type FakeQueryFIPS
- type FakeQueryFetch
- type FakeQueryInterface
- func (f *FakeQueryInterface) AddRecord(coord coordinate.ModuleCoordinate, pipelineVersion string, ...)
- func (f *FakeQueryInterface) FindSymbol(_ context.Context, _, _ string, scope coordinate.ModuleSet) ([]ifaceports.SymbolRef, error)
- func (f *FakeQueryInterface) GetInterfaceRecord(_ context.Context, coord coordinate.ModuleCoordinate, pipelineVersion string) (ifacedomain.InterfaceRecord, bool, error)
- func (f *FakeQueryInterface) InterfaceHistory(_ context.Context, coord coordinate.ModuleCoordinate, pipelineVersion string) ([]ifacedomain.InterfaceRecord, error)
- func (f *FakeQueryInterface) ListInterfaceGenerations(_ context.Context) ([]ifaceports.InterfaceGeneration, error)
- func (f *FakeQueryInterface) ListInterfaceRecords(_ context.Context, filter ifaceports.InterfaceFilter) ([]ifaceports.InterfaceSummary, error)
- func (f *FakeQueryInterface) SetInterfaceHistory(coord coordinate.ModuleCoordinate, pipelineVersion string, ...)
- func (f *FakeQueryInterface) SetList(sums []ifaceports.InterfaceSummary)
- type FakeQueryLicense
- func (f *FakeQueryLicense) AddRecord(coord coordinate.ModuleCoordinate, pipelineVersion string, ...)
- func (f *FakeQueryLicense) GetLicenseRecord(_ context.Context, coord coordinate.ModuleCoordinate, pipelineVersion string) (licensedomain.LicenseRecord, bool, error)
- func (f *FakeQueryLicense) LicenseHistory(_ context.Context, coord coordinate.ModuleCoordinate, pipelineVersion string) ([]licensedomain.LicenseRecord, error)
- func (f *FakeQueryLicense) ListLicenseRecords(_ context.Context, filter licenseports.LicenseFilter) ([]licenseports.LicenseSummary, error)
- func (f *FakeQueryLicense) PipelinesHeld(_ context.Context, coord coordinate.ModuleCoordinate) ([]string, error)
- func (f *FakeQueryLicense) ResolveForWalk(_ context.Context, _ string, _ coordinate.ModuleCoordinate, ...) ([]licapp.DepLicenseResult, error)
- func (f *FakeQueryLicense) SetHistory(coord coordinate.ModuleCoordinate, pipelineVersion string, ...)
- func (f *FakeQueryLicense) SetList(summaries []licenseports.LicenseSummary)
- func (f *FakeQueryLicense) SetResolveResult(results []licapp.DepLicenseResult)
- type FakeQuerySBOM
- type FakeQueryScanRuns
- func (f *FakeQueryScanRuns) AddRun(run vulndomain.WalkScanRun)
- func (f *FakeQueryScanRuns) AddSnapshot(snap vulndomain.DatabaseSnapshot)
- func (f *FakeQueryScanRuns) GetLatestSnapshot(_ context.Context) (vulndomain.DatabaseSnapshot, bool, error)
- func (f *FakeQueryScanRuns) GetRun(_ context.Context, id string) (vulndomain.WalkScanRun, bool, error)
- func (f *FakeQueryScanRuns) ListAllRuns(_ context.Context) ([]vulndomain.WalkScanRun, error)
- func (f *FakeQueryScanRuns) ListRunsForWalk(_ context.Context, walkID string) ([]vulndomain.WalkScanRun, error)
- func (f *FakeQueryScanRuns) ListSnapshots(_ context.Context) ([]vulndomain.DatabaseSnapshot, error)
- func (f *FakeQueryScanRuns) MarkWalkAbsent(walkID string)
- func (f *FakeQueryScanRuns) UnresolvedWalks(_ context.Context, runs []vulndomain.WalkScanRun) (map[string]bool, error)
- func (f *FakeQueryScanRuns) WalkPresent(_ context.Context, walkID string) (bool, error)
- type FakeQueryVuln
- func (f *FakeQueryVuln) AddRecord(coord coordinate.ModuleCoordinate, rec vulndomain.VulnerabilityRecord)
- func (f *FakeQueryVuln) AddRecords(coord coordinate.ModuleCoordinate, recs ...vulndomain.VulnerabilityRecord)
- func (f *FakeQueryVuln) AddSupersededRecords(coord coordinate.ModuleCoordinate, recs ...vulndomain.VulnerabilityRecord)
- func (f *FakeQueryVuln) ByIDWalkSeen() string
- func (f *FakeQueryVuln) FindingTimelines(_ context.Context, _, walkID string) ([]vulndomain.FindingTimeline, error)
- func (f *FakeQueryVuln) ListRecordGenerationsForModule(_ context.Context, coord coordinate.ModuleCoordinate) ([]vulnports.VulnerabilityRecordGeneration, error)
- func (f *FakeQueryVuln) ListRecordsByFindingID(_ context.Context, _, walkID string) ([]vulndomain.VulnerabilityRecord, error)
- func (f *FakeQueryVuln) ListRecordsForModule(_ context.Context, coord coordinate.ModuleCoordinate, _ string) ([]vulndomain.VulnerabilityRecord, error)
- func (f *FakeQueryVuln) ListRecordsForModuleAllGenerations(ctx context.Context, coord coordinate.ModuleCoordinate) ([]vulndomain.VulnerabilityRecord, error)
- func (f *FakeQueryVuln) ListRecordsForModuleInWalk(_ context.Context, coord coordinate.ModuleCoordinate, _, _ string) ([]vulndomain.VulnerabilityRecord, error)
- func (f *FakeQueryVuln) ListRecordsForRun(_ context.Context, runID string) ([]vulndomain.VulnerabilityRecord, error)
- func (f *FakeQueryVuln) SetByID(recs []vulndomain.VulnerabilityRecord)
- func (f *FakeQueryVuln) SetByIDForWalk(walkID string, recs []vulndomain.VulnerabilityRecord)
- func (f *FakeQueryVuln) SetRecordGenerations(coord coordinate.ModuleCoordinate, ...)
- func (f *FakeQueryVuln) SetRunRecords(runID string, recs []vulndomain.VulnerabilityRecord)
- func (f *FakeQueryVuln) SetTimelines(tls []vulndomain.FindingTimeline)
- type FakeQueryWalks
- func (f *FakeQueryWalks) AddWalk(rec walkdomain.WalkRecord)
- func (f *FakeQueryWalks) GetWalk(_ context.Context, id string) (walkdomain.WalkRecord, error)
- func (f *FakeQueryWalks) ListWalks(_ context.Context, filter walkports.WalkFilter) ([]walkports.WalkSummary, error)
- func (f *FakeQueryWalks) SetSummaries(s []walkports.WalkSummary)
- type FakeRescanWalk
- type FakeScanModule
- type FakeScanWalk
- func (f *FakeScanWalk) JudgeToolchain(_ context.Context, snapshot vulndomain.DatabaseSnapshot, ...) (vulndomain.ToolchainJudgment, error)
- func (f *FakeScanWalk) RefreshSnapshot(_ context.Context, walkID string) (vulnapp.SnapshotRefresh, error)
- func (f *FakeScanWalk) ReusableRun(_ context.Context, walkID, projectDir string) (vulndomain.WalkScanRun, bool, error)
- func (f *FakeScanWalk) Scan(_ context.Context, params vulnapp.ScanWalkParams) (vulndomain.WalkScanRun, error)
- func (f *FakeScanWalk) ServeReusableRun(run vulndomain.WalkScanRun, surface string) error
- type FakeScanWalkProgress
- type ServedRun
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FakeCheckCompatibility ¶
type FakeCheckCompatibility struct {
Report licensedomain.ClosureCompatibilityReport
// ReportByWalk answers per walk id, so a test can give two walks of one
// target genuinely different licence positions — which is the whole point of
// being able to pin one. A walk id absent from the map falls back to Report.
ReportByWalk map[string]licensedomain.ClosureCompatibilityReport
Err error
// AskedWalkIDs records, in order, the walks the command asked about.
AskedWalkIDs []string
}
FakeCheckCompatibility implements cli.CheckCompatibilityUseCase.
func (*FakeCheckCompatibility) CheckCompatibilityForWalk ¶
func (f *FakeCheckCompatibility) CheckCompatibilityForWalk(_ context.Context, walkID string, _ coordinate.ModuleCoordinate, _ string, _ licensedomain.LicenseOverrideSet) (licensedomain.ClosureCompatibilityReport, error)
type FakeDiffDirectives ¶
type FakeDiffDirectives struct {
Result directivedomain.DirectiveDiff
Err error
}
FakeDiffDirectives implements cli.DiffDirectivesUseCase.
func (*FakeDiffDirectives) Diff ¶
func (f *FakeDiffDirectives) Diff(_ context.Context, _, _ string) (directivedomain.DirectiveDiff, error)
type FakeDiffInterface ¶
type FakeDiffInterface struct {
Result ifacedomain.InterfaceDiff
Err error
}
FakeDiffInterface implements cli.DiffInterfaceUseCase.
func (*FakeDiffInterface) Diff ¶
func (f *FakeDiffInterface) Diff(_ context.Context, _, _ coordinate.ModuleCoordinate) (ifacedomain.InterfaceDiff, error)
type FakeDiffLicense ¶
type FakeDiffLicense struct {
Result licensedomain.LicenseDiff
Err error
}
FakeDiffLicense implements cli.DiffLicenseUseCase.
func (*FakeDiffLicense) Diff ¶
func (f *FakeDiffLicense) Diff(_ context.Context, _, _ coordinate.ModuleCoordinate) (licensedomain.LicenseDiff, error)
type FakeDiffScanRuns ¶
type FakeDiffScanRuns struct {
Err error
Result vulndomain.ScanRunDiff
}
FakeDiffScanRuns implements cli.DiffScanRunsUseCase.
func (*FakeDiffScanRuns) Diff ¶
func (f *FakeDiffScanRuns) Diff(_ context.Context, _, _ string) (vulndomain.ScanRunDiff, error)
type FakeDiffWalks ¶
FakeDiffWalks implements cli.DiffWalksUseCase.
type FakeExecuteWalk ¶
type FakeExecuteWalk struct {
Err error
Result walkapp.ExecuteWalkResult
LastRequest walkapp.WalkRequest
// Calls counts Execute invocations, so a test can assert that a refused
// flag combination never reached the walk at all.
Calls int
}
FakeExecuteWalk implements cli.ExecuteWalkUseCase. LastRequest captures the most recent request so tests can assert how the CLI translated flags into a WalkRequest.
func (*FakeExecuteWalk) Execute ¶
func (f *FakeExecuteWalk) Execute(_ context.Context, req walkapp.WalkRequest) (walkapp.ExecuteWalkResult, error)
type FakeExtract ¶
type FakeExtract struct {
Err error
Result extractdomain.ExtractionRun
Calls []extractapp.ExtractRequest
}
FakeExtract implements cli.ExtractUseCase. It records each request so tests can assert which stages ran and whether force was set.
func (*FakeExtract) Execute ¶
func (f *FakeExtract) Execute(_ context.Context, req extractapp.ExtractRequest) (extractdomain.ExtractionRun, error)
type FakeExtractCallGraph ¶
type FakeExtractCallGraph struct {
Err error
Result cgapp.ExtractResult
}
FakeExtractCallGraph implements cli.ExtractCallGraphUseCase.
func (*FakeExtractCallGraph) Execute ¶
func (f *FakeExtractCallGraph) Execute(_ context.Context, _ cgapp.ExtractRequest) (cgapp.ExtractResult, error)
type FakeExtractExample ¶
type FakeExtractExample struct {
Err error
Result exapp.ExtractResult
}
FakeExtractExample implements cli.ExtractExampleUseCase.
func (*FakeExtractExample) Execute ¶
func (f *FakeExtractExample) Execute(_ context.Context, _ exapp.ExtractRequest) (exapp.ExtractResult, error)
type FakeExtractFIPS ¶
type FakeExtractFIPS struct {
Err error
Result fipsdomain.Record
}
FakeExtractFIPS implements cli.ExtractFIPSUseCase.
func (*FakeExtractFIPS) Extract ¶
func (f *FakeExtractFIPS) Extract(_ context.Context, _ string, _ configdomain.FIPSPolicy, _ string) (fipsdomain.Record, error)
type FakeExtractInterface ¶
type FakeExtractInterface struct {
Err error
Result ifaceapp.ExtractResult
}
FakeExtractInterface implements cli.ExtractInterfaceUseCase.
func (*FakeExtractInterface) Execute ¶
func (f *FakeExtractInterface) Execute(_ context.Context, _ ifaceapp.ExtractRequest) (ifaceapp.ExtractResult, error)
type FakeExtractLicense ¶
type FakeExtractLicense struct {
Err error
Result licapp.ExtractResult
}
FakeExtractLicense implements cli.ExtractLicenseUseCase.
func (*FakeExtractLicense) Execute ¶
func (f *FakeExtractLicense) Execute(_ context.Context, _ licapp.ExtractRequest) (licapp.ExtractResult, error)
func (*FakeExtractLicense) GetLicenseStore ¶
func (f *FakeExtractLicense) GetLicenseStore() licenseports.LicenseStore
type FakeFetchModule ¶
type FakeFetchModule struct {
Err error
Result fetchapp.FetchResult
}
FakeFetchModule implements cli.FetchModuleUseCase.
func (*FakeFetchModule) Execute ¶
func (f *FakeFetchModule) Execute(_ context.Context, _ fetchapp.FetchRequest) (fetchapp.FetchResult, error)
type FakeGenerateNotice ¶
type FakeGenerateNotice struct {
Result licapp.NoticeResult
Err error
// LastRequest records what the caller asked for, so a test can assert on
// inputs the fake result cannot reflect — the operator's recorded copyright
// declarations among them.
LastRequest licapp.NoticeRequest
}
FakeGenerateNotice implements cli.GenerateNoticeUseCase.
func (*FakeGenerateNotice) Generate ¶
func (f *FakeGenerateNotice) Generate(_ context.Context, req licapp.NoticeRequest) (licapp.NoticeResult, error)
type FakeGenerateSBOM ¶
type FakeGenerateSBOM struct {
Err error
Result sbomdomain.SBOMRecord
LastRequest sbomapp.SBOMRequest
}
FakeGenerateSBOM implements cli.GenerateSBOMUseCase.
func (*FakeGenerateSBOM) Generate ¶
func (f *FakeGenerateSBOM) Generate(_ context.Context, req sbomapp.SBOMRequest) (sbomdomain.SBOMRecord, error)
type FakeQueryCallGraph ¶
type FakeQueryCallGraph struct {
// ListCalls counts calls to this fake's listing method, so a test can
// assert that a listing which returned rows read the store exactly once and
// did not also pay the survey read the zero-result notice needs.
ListCalls int
// CoordinateListCalls counts calls to the column-only listing, and RecordReads
// every composed record read.
//
// They are counted separately from ListCalls because the difference between
// them IS the behaviour: an edge query asks which modules the store has
// analysed, which is a question about coordinates, and answering it through
// the composing listing decodes every generation of every multi-generation
// coordinate in the store to read fields no part of the answer looks at.
CoordinateListCalls int
// Unserved is what UnservedCoordinates answers, for the coordinates asked.
Unserved []cgports.UnservedCoordinate
// HistoryCalls counts the composing history read — the one that reconstructs
// and verifies every generation's edge set. It is counted separately from
// RecordReads because a caller that needs one COLUMN per generation must not
// reach it: reading the analyser through it was a second complete pass over
// the coordinate, on top of the one composition had already done.
HistoryCalls int
RecordReads int
// ForeignModuleReads counts the column read that qualifies an answer. It is
// separate from RecordReads because in the store it IS separate: a column
// beside the record, read without decompressing or decoding one, which is the
// whole reason the column exists.
ForeignModuleReads int
Err error
// contains filtered or unexported fields
}
FakeQueryCallGraph implements cli.QueryCallGraphUseCase.
func NewFakeQueryCallGraph ¶
func NewFakeQueryCallGraph() *FakeQueryCallGraph
func (*FakeQueryCallGraph) AddGeneration ¶
func (f *FakeQueryCallGraph) AddGeneration(coord coordinate.ModuleCoordinate, pipelineVersion string, rec cgdomain.CallGraphRecord)
AddGeneration appends a record to the coordinate's history without changing what GetCallGraphRecord serves, so a test can set up a ledger holding several generations and a composed answer independently.
func (*FakeQueryCallGraph) AddRecord ¶
func (f *FakeQueryCallGraph) AddRecord(coord coordinate.ModuleCoordinate, pipelineVersion string, rec cgdomain.CallGraphRecord)
func (*FakeQueryCallGraph) CallGraphHistory ¶
func (f *FakeQueryCallGraph) CallGraphHistory(ctx context.Context, coord coordinate.ModuleCoordinate, pipelineVersion string) ([]cgdomain.CallGraphRecord, error)
func (*FakeQueryCallGraph) FindCallees ¶
func (f *FakeQueryCallGraph) FindCallees(_ context.Context, _, _ string, scope coordinate.ModuleSet, opts cgports.EdgeQueryOptions) ([]cgports.CallEdgeRef, error)
func (*FakeQueryCallGraph) FindCallers ¶
func (f *FakeQueryCallGraph) FindCallers(_ context.Context, symbolID, _ string, scope coordinate.ModuleSet, opts cgports.EdgeQueryOptions) ([]cgports.CallEdgeRef, error)
func (*FakeQueryCallGraph) ForeignModulesBuilt ¶
func (f *FakeQueryCallGraph) ForeignModulesBuilt(_ context.Context, coord coordinate.ModuleCoordinate, pipelineVersion string, _ gotoolchain.Version) ([]cgdomain.ForeignModule, bool, error)
ForeignModulesBuilt answers from the added record's own field, which is what the store's derived column holds: the write leg copies it out of the record in the same transaction as the blob, so the two can never disagree. It counts no record read, because reading the column is not one.
func (*FakeQueryCallGraph) GetCallGraphRecord ¶
func (f *FakeQueryCallGraph) GetCallGraphRecord(_ context.Context, coord coordinate.ModuleCoordinate, pipelineVersion string) (cgdomain.CallGraphRecord, bool, error)
func (*FakeQueryCallGraph) GetCallGraphRecordFrom ¶
func (f *FakeQueryCallGraph) GetCallGraphRecordFrom(ctx context.Context, coord coordinate.ModuleCoordinate, pipelineVersion string, req cgdomain.ComposeRequest) (cgdomain.CallGraphRecord, bool, error)
func (*FakeQueryCallGraph) ListCallGraphCoordinates ¶
func (f *FakeQueryCallGraph) ListCallGraphCoordinates(_ context.Context, filter cgports.CallGraphFilter) ([]cgports.CallGraphCoordinate, error)
ListCallGraphCoordinates projects the same filtered listing onto the ledger's keys.
The flags are read off the RECORDS the fake holds, not off the summaries. A real store reads them from denormalised columns that a write puts there from the record itself, so the two can never disagree; in the fake they are set independently, and deriving the flags from the summary would let a test whose summary says nothing hide a Partial record the resolution helpers must see.
func (*FakeQueryCallGraph) ListCallGraphRecords ¶
func (f *FakeQueryCallGraph) ListCallGraphRecords(_ context.Context, filter cgports.CallGraphFilter) ([]cgports.CallGraphSummary, error)
ListCallGraphRecords applies the filter the SQLite adapter applies: exact equality on the module path, then offset, then limit. A fake that returned everything regardless would let a filter defect pass every test that used it.
func (*FakeQueryCallGraph) NotSearchedByCallees ¶
func (f *FakeQueryCallGraph) NotSearchedByCallees(context.Context, []string, string, coordinate.ModuleSet, cgports.EdgeQueryOptions) ([]cgports.UnservedCoordinate, error)
NotSearchedByCallees names nothing, as NotSearchedByCallers.
func (*FakeQueryCallGraph) NotSearchedByCallers ¶
func (f *FakeQueryCallGraph) NotSearchedByCallers(context.Context, []string, string, coordinate.ModuleSet, cgports.EdgeQueryOptions) ([]cgports.UnservedCoordinate, error)
NotSearchedByCallers names nothing: the fake holds one generation per coordinate, so nothing it holds is superseded.
func (*FakeQueryCallGraph) SetCallees ¶
func (f *FakeQueryCallGraph) SetCallees(refs []cgports.CallEdgeRef)
func (*FakeQueryCallGraph) SetCallers ¶
func (f *FakeQueryCallGraph) SetCallers(refs []cgports.CallEdgeRef)
func (*FakeQueryCallGraph) SetCallersFor ¶
func (f *FakeQueryCallGraph) SetCallersFor(symbolID string, refs []cgports.CallEdgeRef)
SetCallersFor answers one symbol specifically. A command that queries several symbols in one run needs the fake to tell them apart; SetCallers alone would return the same edges for every one of them, and a join that queried the wrong symbol would still pass.
func (*FakeQueryCallGraph) SetGetErr ¶
func (f *FakeQueryCallGraph) SetGetErr(err error)
SetGetErr makes record reads fail while listing still succeeds, so a caller that must surface a store failure rather than report an empty answer can be tested at the point the read happens.
func (*FakeQueryCallGraph) SetList ¶
func (f *FakeQueryCallGraph) SetList(summaries []cgports.CallGraphSummary)
func (*FakeQueryCallGraph) SetTraverseCallees ¶
func (f *FakeQueryCallGraph) SetTraverseCallees(edges []cgports.CallEdgeRef, nodes []string)
func (*FakeQueryCallGraph) SetTraverseCalleesTruncated ¶
func (f *FakeQueryCallGraph) SetTraverseCalleesTruncated(truncated bool)
SetTraverseCalleesTruncated is SetTraverseCallersTruncated for the other direction.
func (*FakeQueryCallGraph) SetTraverseCallers ¶
func (f *FakeQueryCallGraph) SetTraverseCallers(edges []cgports.CallEdgeRef, nodes []string)
func (*FakeQueryCallGraph) SetTraverseCallersTruncated ¶
func (f *FakeQueryCallGraph) SetTraverseCallersTruncated(truncated bool)
SetTraverseCallersTruncated makes the next caller traversal report that it stopped holding an unexpanded frontier. It is a separate setter from the answer itself because the two are independent: the same nodes and edges are returned whether or not the walk had more to follow, which is the whole difference the marker exists to state.
func (*FakeQueryCallGraph) TraversalRequests ¶
func (f *FakeQueryCallGraph) TraversalRequests() []cgapp.TraversalRequest
TraversalRequests returns every request the fake was asked, in order, so a test can assert what the command plumbed through — the depth bound and the progress reporter included.
func (*FakeQueryCallGraph) TraverseCallees ¶
func (f *FakeQueryCallGraph) TraverseCallees(_ context.Context, req cgapp.TraversalRequest) (cgapp.TraversalResult, error)
func (*FakeQueryCallGraph) TraverseCallers ¶
func (f *FakeQueryCallGraph) TraverseCallers(_ context.Context, req cgapp.TraversalRequest) (cgapp.TraversalResult, error)
func (*FakeQueryCallGraph) UnservedCoordinates ¶
func (f *FakeQueryCallGraph) UnservedCoordinates(_ context.Context, coords []coordinate.ModuleCoordinate, _ string) ([]cgports.UnservedCoordinate, error)
UnservedCoordinates names nothing, as NotSearchedByCallers.
type FakeQueryDirectives ¶
type FakeQueryDirectives struct {
Scan directivedomain.Record
Found bool
Scans []directivedomain.Record
GetErr error
ListErr error
// StoreScans is how many scans the whole store holds, across every project.
// Zero means "the same as Scans": the common fixture has one project and no
// reason to distinguish the two, and a fixture that wants a store holding
// scans for OTHER projects sets it explicitly.
StoreScans int
CountErr error
// Projects is what ListScanProjects names; nil reads as a store that
// cannot enumerate them.
Projects []string
// ListCalls counts calls to ListScans, so a test can assert that a listing
// which returned rows read the store once and did not also pay the
// zero-result survey.
ListCalls int
}
FakeQueryDirectives implements cli.QueryDirectivesUseCase.
func (*FakeQueryDirectives) CountScans ¶
func (f *FakeQueryDirectives) CountScans(context.Context) (int, error)
func (*FakeQueryDirectives) GetScan ¶
func (f *FakeQueryDirectives) GetScan(_ context.Context, _ string) (directivedomain.Record, bool, error)
func (*FakeQueryDirectives) ListScanProjects ¶ added in v0.16.1
func (*FakeQueryDirectives) ListScans ¶
func (f *FakeQueryDirectives) ListScans(_ context.Context, _ string, limit, offset int) ([]directivedomain.Record, error)
type FakeQueryExamples ¶
type FakeQueryExamples struct {
// ListCalls counts calls to this fake's listing method, so a test can
// assert that a listing which returned rows read the store exactly once and
// did not also pay the survey read the zero-result notice needs.
ListCalls int
// ListFilters records every filter the listing method was given, so a test
// can assert what a listing asked the store for.
ListFilters []exports.ExampleFilter
Err error
// contains filtered or unexported fields
}
FakeQueryExamples implements cli.QueryExamplesUseCase.
func NewFakeQueryExamples ¶
func NewFakeQueryExamples() *FakeQueryExamples
func (*FakeQueryExamples) AddRecord ¶
func (f *FakeQueryExamples) AddRecord(coord coordinate.ModuleCoordinate, pipelineVersion string, rec exdomain.ExampleRecord)
func (*FakeQueryExamples) ExampleHistory ¶
func (f *FakeQueryExamples) ExampleHistory(_ context.Context, coord coordinate.ModuleCoordinate, pipelineVersion string) ([]exdomain.ExampleRecord, error)
func (*FakeQueryExamples) FindBySymbol ¶
func (f *FakeQueryExamples) FindBySymbol(_ context.Context, _, _ string, _ coordinate.ModuleSet) ([]exports.ExampleRef, error)
func (*FakeQueryExamples) FindBySymbolInModule ¶
func (f *FakeQueryExamples) FindBySymbolInModule(_ context.Context, coord coordinate.ModuleCoordinate, _, _ string) ([]exports.ExampleRef, error)
func (*FakeQueryExamples) GetExampleRecord ¶
func (f *FakeQueryExamples) GetExampleRecord(_ context.Context, coord coordinate.ModuleCoordinate, pipelineVersion string) (exdomain.ExampleRecord, bool, error)
func (*FakeQueryExamples) ListExampleRecords ¶
func (f *FakeQueryExamples) ListExampleRecords(_ context.Context, filter exports.ExampleFilter) ([]exports.ExampleSummary, error)
func (*FakeQueryExamples) PipelinesHeld ¶
func (f *FakeQueryExamples) PipelinesHeld(_ context.Context, coord coordinate.ModuleCoordinate) ([]string, error)
PipelinesHeld derives the pipelines held from the keys AddRecord and SetHistory filed.
func (*FakeQueryExamples) SetHistory ¶
func (f *FakeQueryExamples) SetHistory(coord coordinate.ModuleCoordinate, pipelineVersion string, recs []exdomain.ExampleRecord)
SetHistory sets the generations ExampleHistory returns for a coordinate.
func (*FakeQueryExamples) SetList ¶
func (f *FakeQueryExamples) SetList(sums []exports.ExampleSummary)
func (*FakeQueryExamples) SetRefs ¶
func (f *FakeQueryExamples) SetRefs(refs []exports.ExampleRef)
type FakeQueryExtraction ¶
type FakeQueryExtraction struct {
// ListCalls counts calls to this fake's listing method, so a test can
// assert that a listing which returned rows read the store exactly once and
// did not also pay the survey read the zero-result notice needs.
ListCalls int
Err error
// contains filtered or unexported fields
}
FakeQueryExtraction implements cli.QueryExtractionUseCase.
func NewFakeQueryExtraction ¶
func NewFakeQueryExtraction() *FakeQueryExtraction
func (*FakeQueryExtraction) AddRun ¶
func (f *FakeQueryExtraction) AddRun(run extractdomain.ExtractionRun)
func (*FakeQueryExtraction) GetExtractionRun ¶
func (f *FakeQueryExtraction) GetExtractionRun(_ context.Context, id string) (extractdomain.ExtractionRun, error)
func (*FakeQueryExtraction) ListExtractionRuns ¶
func (f *FakeQueryExtraction) ListExtractionRuns(_ context.Context, filter extractports.ExtractionRunFilter) ([]extractports.ExtractionRunSummary, error)
func (*FakeQueryExtraction) SetList ¶
func (f *FakeQueryExtraction) SetList(sums []extractports.ExtractionRunSummary)
SetList sets the summaries ListExtractionRuns pages over.
type FakeQueryFIPS ¶
type FakeQueryFIPS struct {
Err error
// contains filtered or unexported fields
}
FakeQueryFIPS implements cli.QueryFIPSUseCase.
func NewFakeQueryFIPS ¶
func NewFakeQueryFIPS() *FakeQueryFIPS
func (*FakeQueryFIPS) Add ¶
func (f *FakeQueryFIPS) Add(projectModulePath string, rec fipsdomain.Record)
func (*FakeQueryFIPS) Get ¶
func (f *FakeQueryFIPS) Get(_ context.Context, projectModulePath string) (fipsdomain.Record, bool, error)
type FakeQueryFetch ¶
type FakeQueryFetch struct {
Err error
// contains filtered or unexported fields
}
FakeQueryFetch implements cli.QueryFetchUseCase.
func NewFakeQueryFetch ¶
func NewFakeQueryFetch() *FakeQueryFetch
func (*FakeQueryFetch) Add ¶
func (f *FakeQueryFetch) Add(coord coordinate.ModuleCoordinate, pipelineVersion string, rec fetchdomain.FactRecord)
func (*FakeQueryFetch) GetFetchRecord ¶
func (f *FakeQueryFetch) GetFetchRecord(_ context.Context, coord coordinate.ModuleCoordinate, pipelineVersion string) (fetchdomain.FactRecord, bool, error)
type FakeQueryInterface ¶
type FakeQueryInterface struct {
// ListCalls counts calls to this fake's listing method, so a test can
// assert that a listing which returned rows read the store exactly once and
// did not also pay the survey read the zero-result notice needs.
ListCalls int
// ListFilters records every filter this fake was asked for, in order, so a
// test can assert WHAT was asked as well as how often. A per-coordinate
// question served from an unfiltered read is a defect the count alone
// cannot see.
ListFilters []ifaceports.InterfaceFilter
Err error
// contains filtered or unexported fields
}
FakeQueryInterface implements cli.QueryInterfaceUseCase.
func NewFakeQueryInterface ¶
func NewFakeQueryInterface() *FakeQueryInterface
func (*FakeQueryInterface) AddRecord ¶
func (f *FakeQueryInterface) AddRecord(coord coordinate.ModuleCoordinate, pipelineVersion string, rec ifacedomain.InterfaceRecord)
AddRecord sets the composed record GetInterfaceRecord returns for a coordinate.
func (*FakeQueryInterface) FindSymbol ¶
func (f *FakeQueryInterface) FindSymbol(_ context.Context, _, _ string, scope coordinate.ModuleSet) ([]ifaceports.SymbolRef, error)
func (*FakeQueryInterface) GetInterfaceRecord ¶
func (f *FakeQueryInterface) GetInterfaceRecord(_ context.Context, coord coordinate.ModuleCoordinate, pipelineVersion string) (ifacedomain.InterfaceRecord, bool, error)
func (*FakeQueryInterface) InterfaceHistory ¶
func (f *FakeQueryInterface) InterfaceHistory(_ context.Context, coord coordinate.ModuleCoordinate, pipelineVersion string) ([]ifacedomain.InterfaceRecord, error)
func (*FakeQueryInterface) ListInterfaceGenerations ¶
func (f *FakeQueryInterface) ListInterfaceGenerations(_ context.Context) ([]ifaceports.InterfaceGeneration, error)
ListInterfaceGenerations names each (module, version, pipeline) the list holds once. It counts as a listing read in ListCalls.
func (*FakeQueryInterface) ListInterfaceRecords ¶
func (f *FakeQueryInterface) ListInterfaceRecords(_ context.Context, filter ifaceports.InterfaceFilter) ([]ifaceports.InterfaceSummary, error)
func (*FakeQueryInterface) SetInterfaceHistory ¶
func (f *FakeQueryInterface) SetInterfaceHistory(coord coordinate.ModuleCoordinate, pipelineVersion string, recs []ifacedomain.InterfaceRecord)
SetInterfaceHistory sets the generations InterfaceHistory returns for a coordinate.
func (*FakeQueryInterface) SetList ¶
func (f *FakeQueryInterface) SetList(sums []ifaceports.InterfaceSummary)
SetList sets the summaries ListInterfaceRecords pages over.
type FakeQueryLicense ¶
type FakeQueryLicense struct {
// ListCalls counts calls to this fake's listing method, so a test can
// assert that a listing which returned rows read the store exactly once and
// did not also pay the survey read the zero-result notice needs.
ListCalls int
Err error
// contains filtered or unexported fields
}
FakeQueryLicense implements cli.QueryLicenseUseCase.
func NewFakeQueryLicense ¶
func NewFakeQueryLicense() *FakeQueryLicense
func (*FakeQueryLicense) AddRecord ¶
func (f *FakeQueryLicense) AddRecord(coord coordinate.ModuleCoordinate, pipelineVersion string, rec licensedomain.LicenseRecord)
func (*FakeQueryLicense) GetLicenseRecord ¶
func (f *FakeQueryLicense) GetLicenseRecord(_ context.Context, coord coordinate.ModuleCoordinate, pipelineVersion string) (licensedomain.LicenseRecord, bool, error)
func (*FakeQueryLicense) LicenseHistory ¶
func (f *FakeQueryLicense) LicenseHistory(_ context.Context, coord coordinate.ModuleCoordinate, pipelineVersion string) ([]licensedomain.LicenseRecord, error)
func (*FakeQueryLicense) ListLicenseRecords ¶
func (f *FakeQueryLicense) ListLicenseRecords(_ context.Context, filter licenseports.LicenseFilter) ([]licenseports.LicenseSummary, error)
ListLicenseRecords applies the filter the SQLite adapter applies: exact equality on the primary SPDX identifier, the pipeline version and the copyright status, then the offset, then the limit.
func (*FakeQueryLicense) PipelinesHeld ¶
func (f *FakeQueryLicense) PipelinesHeld(_ context.Context, coord coordinate.ModuleCoordinate) ([]string, error)
PipelinesHeld derives the pipelines held from the keys AddRecord and SetHistory filed, so a record added at a superseded pipeline is visible to the superseded diagnostic exactly as the store's own index makes it.
func (*FakeQueryLicense) ResolveForWalk ¶
func (f *FakeQueryLicense) ResolveForWalk(_ context.Context, _ string, _ coordinate.ModuleCoordinate, _ func(context.Context, coordinate.ModuleCoordinate) (licensedomain.LicenseRecord, error)) ([]licapp.DepLicenseResult, error)
func (*FakeQueryLicense) SetHistory ¶
func (f *FakeQueryLicense) SetHistory(coord coordinate.ModuleCoordinate, pipelineVersion string, recs []licensedomain.LicenseRecord)
History is the generation list LicenseHistory returns, keyed by "coordinate|pipelineVersion" like records.
func (*FakeQueryLicense) SetList ¶
func (f *FakeQueryLicense) SetList(summaries []licenseports.LicenseSummary)
func (*FakeQueryLicense) SetResolveResult ¶
func (f *FakeQueryLicense) SetResolveResult(results []licapp.DepLicenseResult)
type FakeQuerySBOM ¶
type FakeQuerySBOM struct {
Err error
// contains filtered or unexported fields
}
FakeQuerySBOM implements cli.QuerySBOMUseCase.
func NewFakeQuerySBOM ¶
func NewFakeQuerySBOM() *FakeQuerySBOM
func (*FakeQuerySBOM) GetSBOMRecord ¶
func (f *FakeQuerySBOM) GetSBOMRecord(_ context.Context, id string) (sbomdomain.SBOMRecord, error)
func (*FakeQuerySBOM) ListSBOMRecords ¶
func (f *FakeQuerySBOM) ListSBOMRecords(_ context.Context, _ string) ([]sbomdomain.SBOMRecord, error)
type FakeQueryScanRuns ¶
type FakeQueryScanRuns struct {
// ListCalls counts calls to this fake's listing method, so a test can
// assert that a listing which returned rows read the store exactly once and
// did not also pay the survey read the zero-result notice needs.
ListCalls int
GetErr error
ListErr error
// AbsentWalks are the walk ids this store no longer holds — the runs naming
// them have inputs that cannot be resolved. Empty (the default) means every
// seeded run's walk resolves, which is the healthy store.
AbsentWalks map[string]bool
// PresenceErr, when set, is what the walk-presence probe fails with. A reader
// that cannot check must not answer, so commands surface it rather than
// rendering the run as ordinary.
PresenceErr error
// contains filtered or unexported fields
}
FakeQueryScanRuns implements cli.QueryScanRunsUseCase.
func NewFakeQueryScanRuns ¶
func NewFakeQueryScanRuns() *FakeQueryScanRuns
func (*FakeQueryScanRuns) AddRun ¶
func (f *FakeQueryScanRuns) AddRun(run vulndomain.WalkScanRun)
func (*FakeQueryScanRuns) AddSnapshot ¶
func (f *FakeQueryScanRuns) AddSnapshot(snap vulndomain.DatabaseSnapshot)
func (*FakeQueryScanRuns) GetLatestSnapshot ¶
func (f *FakeQueryScanRuns) GetLatestSnapshot(_ context.Context) (vulndomain.DatabaseSnapshot, bool, error)
func (*FakeQueryScanRuns) GetRun ¶
func (f *FakeQueryScanRuns) GetRun(_ context.Context, id string) (vulndomain.WalkScanRun, bool, error)
func (*FakeQueryScanRuns) ListAllRuns ¶
func (f *FakeQueryScanRuns) ListAllRuns(_ context.Context) ([]vulndomain.WalkScanRun, error)
ListAllRuns returns every seeded run, on the same partial-result terms as ListRunsForWalk.
func (*FakeQueryScanRuns) ListRunsForWalk ¶
func (f *FakeQueryScanRuns) ListRunsForWalk(_ context.Context, walkID string) ([]vulndomain.WalkScanRun, error)
ListRunsForWalk returns the seeded runs for walkID. ListErr is returned ALONGSIDE them, not instead of them: the real store reports the rows it could not verify while still handing back the ones it could, and a fake that withheld them would let a survey command pass a test it fails in production.
func (*FakeQueryScanRuns) ListSnapshots ¶
func (f *FakeQueryScanRuns) ListSnapshots(_ context.Context) ([]vulndomain.DatabaseSnapshot, error)
func (*FakeQueryScanRuns) MarkWalkAbsent ¶
func (f *FakeQueryScanRuns) MarkWalkAbsent(walkID string)
MarkWalkAbsent seeds a walk id as purged from the store, so the runs naming it are the dangling ones.
func (*FakeQueryScanRuns) UnresolvedWalks ¶
func (f *FakeQueryScanRuns) UnresolvedWalks( _ context.Context, runs []vulndomain.WalkScanRun, ) (map[string]bool, error)
UnresolvedWalks names the walks among runs that this fake reports as absent.
func (*FakeQueryScanRuns) WalkPresent ¶
WalkPresent reports whether walkID is still held.
type FakeQueryVuln ¶
type FakeQueryVuln struct {
Err error
// PartialErr is returned ALONGSIDE the records a listing found, the way a
// store reports rows it could not verify while still handing back the ones it
// could. Err aborts instead, returning nothing: the two are different
// failures, and a fake that could only express one could not test the
// difference between a listing that withholds its answer and one that names
// what is missing from it.
PartialErr error
// ForceLatestRecordForWalkNotFound empties the walk-scoped candidate read
// regardless of the records map.
ForceLatestRecordForWalkNotFound bool
// contains filtered or unexported fields
}
FakeQueryVuln implements cli.QueryVulnUseCase.
func NewFakeQueryVuln ¶
func NewFakeQueryVuln() *FakeQueryVuln
func (*FakeQueryVuln) AddRecord ¶
func (f *FakeQueryVuln) AddRecord(coord coordinate.ModuleCoordinate, rec vulndomain.VulnerabilityRecord)
func (*FakeQueryVuln) AddRecords ¶
func (f *FakeQueryVuln) AddRecords(coord coordinate.ModuleCoordinate, recs ...vulndomain.VulnerabilityRecord)
AddRecords seeds every generation the ledger holds for one coordinate, which is what a frame-aware read consults. The first is also the coordinate's single-record answer, so a test that seeds a ledger does not have to seed the composed read separately.
func (*FakeQueryVuln) AddSupersededRecords ¶
func (f *FakeQueryVuln) AddSupersededRecords(coord coordinate.ModuleCoordinate, recs ...vulndomain.VulnerabilityRecord)
AddSupersededRecords seeds records the store holds at a generation this build does not serve. Only ListRecordsForModuleAllGenerations returns them, so a test can reproduce a coordinate whose whole history is dark to the keyed reads while the rows are still in the store.
func (*FakeQueryVuln) ByIDWalkSeen ¶
func (f *FakeQueryVuln) ByIDWalkSeen() string
ByIDWalkSeen returns the walk ID the last ListRecordsByFindingID call carried, so a test can prove the flag reached the use case rather than being dropped.
func (*FakeQueryVuln) FindingTimelines ¶
func (f *FakeQueryVuln) FindingTimelines(_ context.Context, _, walkID string) ([]vulndomain.FindingTimeline, error)
FindingTimelines returns the seeded timelines beside PartialErr, or Err.
func (*FakeQueryVuln) ListRecordGenerationsForModule ¶
func (f *FakeQueryVuln) ListRecordGenerationsForModule(_ context.Context, coord coordinate.ModuleCoordinate) ([]vulnports.VulnerabilityRecordGeneration, error)
ListRecordGenerationsForModule answers the census. An unseeded coordinate holds nothing, which is the "never scanned" case.
func (*FakeQueryVuln) ListRecordsByFindingID ¶
func (f *FakeQueryVuln) ListRecordsByFindingID(_ context.Context, _, walkID string) ([]vulndomain.VulnerabilityRecord, error)
func (*FakeQueryVuln) ListRecordsForModule ¶
func (f *FakeQueryVuln) ListRecordsForModule(_ context.Context, coord coordinate.ModuleCoordinate, _ string) ([]vulndomain.VulnerabilityRecord, error)
func (*FakeQueryVuln) ListRecordsForModuleAllGenerations ¶
func (f *FakeQueryVuln) ListRecordsForModuleAllGenerations(ctx context.Context, coord coordinate.ModuleCoordinate) ([]vulndomain.VulnerabilityRecord, error)
ListRecordsForModuleAllGenerations returns what the keyed read returns plus the rows seeded through AddSupersededRecords, which no other read here sees. The superseded rows come last: the fake seeds no timestamps of its own, and a listing that puts them first would pass a test the real newest-first ordering would fail.
func (*FakeQueryVuln) ListRecordsForModuleInWalk ¶
func (f *FakeQueryVuln) ListRecordsForModuleInWalk(_ context.Context, coord coordinate.ModuleCoordinate, _, _ string) ([]vulndomain.VulnerabilityRecord, error)
ListRecordsForModuleInWalk returns the walk's candidate records for a coordinate: the ledger's generations when one has been seeded, otherwise the single record the map holds. ForceLatestRecordForWalkNotFound empties it, the same way it empties the composed read below.
func (*FakeQueryVuln) ListRecordsForRun ¶
func (f *FakeQueryVuln) ListRecordsForRun(_ context.Context, runID string) ([]vulndomain.VulnerabilityRecord, error)
func (*FakeQueryVuln) SetByID ¶
func (f *FakeQueryVuln) SetByID(recs []vulndomain.VulnerabilityRecord)
func (*FakeQueryVuln) SetByIDForWalk ¶
func (f *FakeQueryVuln) SetByIDForWalk(walkID string, recs []vulndomain.VulnerabilityRecord)
SetByIDForWalk seeds the answer a walk-scoped vuln-by-id query gets. Walks with no entry are reported as never scanned.
func (*FakeQueryVuln) SetRecordGenerations ¶
func (f *FakeQueryVuln) SetRecordGenerations(coord coordinate.ModuleCoordinate, gens []vulnports.VulnerabilityRecordGeneration)
SetRecordGenerations seeds the store census for a coordinate.
func (*FakeQueryVuln) SetRunRecords ¶
func (f *FakeQueryVuln) SetRunRecords(runID string, recs []vulndomain.VulnerabilityRecord)
SetRunRecords seeds the records one scan run wrote, which is what a served run's report is rebuilt from.
func (*FakeQueryVuln) SetTimelines ¶
func (f *FakeQueryVuln) SetTimelines(tls []vulndomain.FindingTimeline)
SetTimelines seeds the answer FindingTimelines gives.
type FakeQueryWalks ¶
type FakeQueryWalks struct {
// ListCalls counts calls to this fake's listing method, so a test can
// assert that a listing which returned rows read the store exactly once and
// did not also pay the survey read the zero-result notice needs.
ListCalls int
GetErr error
ListErr error
// contains filtered or unexported fields
}
FakeQueryWalks implements cli.QueryWalksUseCase.
func NewFakeQueryWalks ¶
func NewFakeQueryWalks() *FakeQueryWalks
func (*FakeQueryWalks) AddWalk ¶
func (f *FakeQueryWalks) AddWalk(rec walkdomain.WalkRecord)
func (*FakeQueryWalks) GetWalk ¶
func (f *FakeQueryWalks) GetWalk(_ context.Context, id string) (walkdomain.WalkRecord, error)
func (*FakeQueryWalks) ListWalks ¶
func (f *FakeQueryWalks) ListWalks(_ context.Context, filter walkports.WalkFilter) ([]walkports.WalkSummary, error)
func (*FakeQueryWalks) SetSummaries ¶
func (f *FakeQueryWalks) SetSummaries(s []walkports.WalkSummary)
type FakeRescanWalk ¶
type FakeRescanWalk struct {
Err error
Result vulndomain.WalkScanRun
}
FakeRescanWalk implements cli.RescanWalkUseCase.
func (*FakeRescanWalk) Rescan ¶
func (f *FakeRescanWalk) Rescan(_ context.Context, _ vulnapp.RescanRequest) (vulndomain.WalkScanRun, error)
type FakeScanModule ¶
type FakeScanModule struct {
Err error
Result vulndomain.VulnerabilityRecord
}
FakeScanModule implements cli.ScanModuleUseCase.
func (*FakeScanModule) Scan ¶
func (f *FakeScanModule) Scan(_ context.Context, _ vulnapp.ScanModuleParams) (vulndomain.VulnerabilityRecord, error)
type FakeScanWalk ¶
type FakeScanWalk struct {
Err error
Result vulndomain.WalkScanRun
// ProgressRecords are delivered to the Progress callback (if set) before
// the result is returned. Use this to test output routing in callers.
ProgressRecords []FakeScanWalkProgress
// ReusableRunResult and ReusableRunFound are what ReusableRun reports. The
// zero value reports no reusable run, so a fake that says nothing about reuse
// drives the measuring path, which is what most callers want.
ReusableRunResult vulndomain.WalkScanRun
ReusableRunFound bool
ReusableRunErr error
// ReusableRunWalkID records the walk the last ReusableRun call asked about,
// so a test can prove the reuse question was asked about the walk the run
// executed rather than some other walk of the same target.
ReusableRunWalkID string
// ReusableRunProjectDir records the project directory the last ReusableRun
// call was told about. Whether a stored run may be served depends on that
// directory still building what the walk resolved, so a caller that asks the
// reuse question without naming the tree it would have scanned bypasses the
// check; this records what was named.
ReusableRunProjectDir string
// ReusableRunProjectDirSet reports that ReusableRun was called at all, so a
// test can tell "asked with no directory" from "never asked".
ReusableRunProjectDirSet bool
// ServedRuns records every (run id, surface) pair ServeReusableRun was told
// about, so a test can prove a served answer was witnessed exactly once and
// attributed to the surface that asked. ServeReusableRunErr fails the append.
ServedRuns []ServedRun
ServeReusableRunErr error
// ScanCalls counts Scan invocations, so a test can prove a served run did not
// re-measure.
ScanCalls int
// RefreshSnapshotResult and RefreshSnapshotErr are what RefreshSnapshot
// reports; RefreshSnapshotCalls counts the calls, so a test can prove a run
// checked the advisory database exactly once — or not at all.
RefreshSnapshotResult vulnapp.SnapshotRefresh
RefreshSnapshotErr error
RefreshSnapshotCalls int
// RefreshSnapshotWalkID records the walk the last refresh restricted its
// advisory comparison to.
RefreshSnapshotWalkID string
// ToolchainAdvisories is what the seeded snapshot is taken to say under its
// toolchain key; ToolchainErr fails the read instead. JudgeToolchain runs the
// real domain judgment over them, so a test seeds advisories rather than a
// conclusion and the fake cannot disagree with the shipped ranking.
ToolchainAdvisories vulndomain.ToolchainAdvisorySet
ToolchainErr error
// ToolchainVersion records the version the last judgment was asked about, so
// a test can prove which of the walk's two toolchain versions was read.
ToolchainVersion string
}
FakeScanWalk implements cli.ScanWalkUseCase.
func (*FakeScanWalk) JudgeToolchain ¶
func (f *FakeScanWalk) JudgeToolchain(_ context.Context, snapshot vulndomain.DatabaseSnapshot, toolchainVersion string) (vulndomain.ToolchainJudgment, error)
JudgeToolchain judges the seeded toolchain advisories with the real domain rule.
func (*FakeScanWalk) RefreshSnapshot ¶
func (f *FakeScanWalk) RefreshSnapshot(_ context.Context, walkID string) (vulnapp.SnapshotRefresh, error)
RefreshSnapshot reports the seeded refresh outcome and counts the call.
func (*FakeScanWalk) ReusableRun ¶
func (f *FakeScanWalk) ReusableRun(_ context.Context, walkID, projectDir string) (vulndomain.WalkScanRun, bool, error)
ReusableRun reports the seeded reusable run, if any.
func (*FakeScanWalk) Scan ¶
func (f *FakeScanWalk) Scan(_ context.Context, params vulnapp.ScanWalkParams) (vulndomain.WalkScanRun, error)
func (*FakeScanWalk) ServeReusableRun ¶
func (f *FakeScanWalk) ServeReusableRun(run vulndomain.WalkScanRun, surface string) error
ServeReusableRun records the serving the caller witnessed.
type FakeScanWalkProgress ¶
type FakeScanWalkProgress struct {
Coord coordinate.ModuleCoordinate
Record vulndomain.VulnerabilityRecord
Index int // 1-based; 0 means use slice position
Total int // 0 means use len(ProgressRecords)
}
FakeScanWalkProgress is one entry delivered to the Progress callback.