tests

package
v0.31.1 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package tests contains integration test helpers and fixture schemas shared between integration and fixture-generation tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SampleKey

func SampleKey(level int, p SamplePosition) string

SampleKey formats a sampled-tile lookup key. The Reason isn't part of the key — it's metadata.

func SaveFixture

func SaveFixture(fixturePath string, f *Fixture) error

SaveFixture writes f to fixturePath as indented JSON.

func TestdataDir

func TestdataDir() string

TestdataDir returns the directory holding slide files for integration tests. Resolved from OPENTILE_TESTDIR env var; empty string means integration tests should t.Skip.

func TileKey

func TileKey(level, x, y int) string

TileKey formats a (level, x, y) triple for fixture lookup.

Types

type AssociatedFixture

type AssociatedFixture struct {
	Type        string `json:"kind"`
	Size        [2]int `json:"size"`
	Compression string `json:"compression"`
	SHA256      string `json:"sha256"`
}

AssociatedFixture is the per-associated-image portion of a fixture.

type Fixture

type Fixture struct {
	Slide             string                 `json:"slide"`
	Format            string                 `json:"format"`
	Levels            []LevelFixture         `json:"levels"`
	Metadata          MetadataFixture        `json:"metadata"`
	TileSHA256        map[string]string      `json:"tiles,omitempty"`
	SampledTileSHA256 map[string]SampledTile `json:"sampled_tiles,omitempty"`
	ICCProfileSHA256  string                 `json:"icc_profile_sha256,omitempty"`
	AssociatedImages  []AssociatedFixture    `json:"associated,omitempty"`
	// Images is the multi-image view, populated for files where
	// tiler.Images() returns more than one entry (multi-image OME).
	// When populated, integration tests walk Images instead of the
	// top-level Levels / TileSHA256 / SampledTileSHA256 fields. Each
	// ImageFixture's per-tile hashes are namespaced by image index
	// in the keys so OME images don't collide.
	Images []ImageFixture `json:"images,omitempty"`
}

Fixture is the on-disk schema for a single-slide parity fixture.

The Levels / TileSHA256 / SampledTileSHA256 fields hold the single-image (or Images[0]) view; for multi-image formats (OME-TIFF) the Images field is populated with one entry per main pyramid and integration tests prefer it over the top-level Levels.

func LoadFixture

func LoadFixture(fixturePath string) (*Fixture, error)

LoadFixture reads a Fixture from fixturePath.

type ImageFixture

type ImageFixture struct {
	Index             int                    `json:"index"`
	Name              string                 `json:"name,omitempty"`
	Levels            []LevelFixture         `json:"levels"`
	TileSHA256        map[string]string      `json:"tiles,omitempty"`
	SampledTileSHA256 map[string]SampledTile `json:"sampled_tiles,omitempty"`
}

ImageFixture is one main pyramid in a multi-image fixture. SampledTileSHA256 keys use the image index prefix to avoid collisions across images in the same fixture file.

type LevelFixture

type LevelFixture struct {
	Index       int     `json:"index"`
	Size        [2]int  `json:"size"`
	TileSize    [2]int  `json:"tile_size"`
	Grid        [2]int  `json:"grid"`
	Compression string  `json:"compression"`
	MPPUm       float64 `json:"mpp_um"`
	PyramidIdx  int     `json:"pyramid_index"`
}

type MetadataFixture

type MetadataFixture struct {
	Magnification       float64 `json:"magnification"`
	ScannerManufacturer string  `json:"scanner_manufacturer,omitempty"`
	ScannerSerial       string  `json:"scanner_serial,omitempty"`
	SoftwareLine        string  `json:"software_line,omitempty"`
	MPP                 float64 `json:"mpp_um,omitempty"`
	AcquisitionRFC3339  string  `json:"acquisition_rfc3339,omitempty"`
}

type SamplePosition

type SamplePosition struct {
	X, Y   int
	Reason string
}

SamplePosition is one tile position chosen for a sampled fixture, paired with a label describing which code path it covers.

func SamplePositions

func SamplePositions(grid opentile.Size, imageSize opentile.Size, tileSize opentile.Size) []SamplePosition

SamplePositions returns up to ~16 deliberately-chosen tile positions for a level: nine corner/diagonal/near-edge positions (Layer 1, position- based) plus circumstance-based positions (Layer 2) derived from the level's geometry. Duplicates collapse — bottom-right corner appears only once even though it's reached via both layers.

type SampledTile

type SampledTile struct {
	SHA256 string `json:"sha256"`
	Reason string `json:"reason"`
}

SampledTile is one entry in SampledTileSHA256: a hash paired with a human-readable label describing what code path the tile exercises.

Directories

Path Synopsis
download fetches openslide's public test slides into OPENTILE_TESTDIR.
download fetches openslide's public test slides into OPENTILE_TESTDIR.

Jump to

Keyboard shortcuts

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