testdata

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearCache

func ClearCache()

ClearCache clears the dataset cache (useful for testing)

Types

type CapturedResponse

type CapturedResponse struct {
	URL        string              `json:"url"`
	StatusCode int                 `json:"status_code"`
	Headers    map[string][]string `json:"headers"`
	Body       string              `json:"body"`
	ContentLen int                 `json:"content_len"`
	WordCount  int                 `json:"word_count"`
	LineCount  int                 `json:"line_count"`
	FetchedAt  time.Time           `json:"fetched_at"`
	FetchError string              `json:"fetch_error,omitempty"`
}

CapturedResponse represents a full HTTP response capture for testing

type Dataset

type Dataset struct {
	Name        string
	Description string
	Responses   []CapturedResponse
	Stats       DatasetStats
}

Dataset represents a collection of responses for a specific test scenario

func LoadDataset

func LoadDataset(filename string) (*Dataset, error)

LoadDataset loads a gzipped JSON test dataset Results are cached for performance

func (*Dataset) FilterByContentLenRange

func (d *Dataset) FilterByContentLenRange(minLen, maxLen int) []CapturedResponse

FilterByContentLenRange returns responses within the specified content length range

func (*Dataset) FilterByStatus

func (d *Dataset) FilterByStatus(statusCode int) []CapturedResponse

FilterByStatus returns only responses with the specified status code

func (*Dataset) FilterSuccessful

func (d *Dataset) FilterSuccessful() []CapturedResponse

FilterSuccessful returns only responses that were successfully fetched

func (*Dataset) Top

func (d *Dataset) Top(n int) []CapturedResponse

Top returns the top N responses sorted by content length

type DatasetStats

type DatasetStats struct {
	TotalResponses    int
	SuccessfulFetches int
	FailedFetches     int
	UniqueStatuses    map[int]int
	MinContentLen     int
	MaxContentLen     int
	AvgContentLen     float64
}

DatasetStats provides summary statistics about a dataset

type ResponseData

type ResponseData struct {
	StatusCode int
	Body       string
	Headers    map[string][]string
}

ConvertToResponses converts CapturedResponse slice to a slice that can be converted to anomaly.Response Returns raw data that caller can pass to anomaly.NewResponse()

func ExtractResponseData

func ExtractResponseData(captured []CapturedResponse) []ResponseData

ExtractResponseData converts CapturedResponse slice to ResponseData slice

Jump to

Keyboard shortcuts

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