segments

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package segments builds deterministic segment payloads and identifiers for use by streaming/connection tests.

The fakepool client (internal/testsupport/fakepool) returns whatever bytes you configure for a given message-ID; this package supplies a consistent naming scheme and a recoverable payload format so that a test which downloads segments through the streaming pipeline can verify that the reassembled bytes match what was injected.

Naming

MessageID(i) returns "altmount-test-seg-NNNNNN@fake" — six-digit zero-padded so lexicographic sort matches segment order. Tests pin this format so the fakepool behaviors and the segment-range builder agree without sharing a channel.

Payload shape

Payload(i, size) returns a deterministic byte slice of the requested size. The first 32 bytes encode the segment index in ASCII (left-justified, NUL padded), so a hexdump of any cached buffer instantly shows which segment it came from. The remaining bytes are a repeating pattern derived from i, cheap to generate and stable across runs.

File reassembly

FileBytes(n, size) returns the concatenation of Payload(0..n-1, size). Tests that read a virtual file end-to-end through the streaming pipeline can compare the bytes they receive to this slice to catch ordering or boundary bugs.

Index

Constants

View Source
const MessageIDPrefix = "altmount-test-seg-"

MessageIDPrefix is the constant prefix used for all generated message-IDs. Exposed so fakepool setup loops can sanity-check inputs.

Variables

This section is empty.

Functions

func FileBytes

func FileBytes(n, size int) []byte

FileBytes returns the concatenation of Payload(0..n-1, size). The result is the expected output of a sequential read across n segments.

func MessageID

func MessageID(i int) string

MessageID returns the canonical fake message-ID for the i-th segment.

func Payload

func Payload(i, size int) []byte

Payload returns a deterministic byte slice for segment i. Bytes 0..31 encode the index in ASCII; the remainder follow a stable cheap pattern. Length is always exactly size. A size <= 0 returns nil.

Types

This section is empty.

Jump to

Keyboard shortcuts

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