adformattest

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Overview

Package adformattest provides test fixtures for adformat — the counterpart of admodels/types.MockFormats(), but backed by embed.FS (via adformat/examples) instead of the old, fragile runtime.Caller(1) + os.Open("../assets/...") pair, which broke when a package was moved or vendored.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatByCodename

func FormatByCodename(codename string) *adformat.Format

FormatByCodename returns the mock format with the given codename, or nil. A small convenience on top of MockFormats() for tests that only care about one specific example.

func MockFormats

func MockFormats() []*adformat.Format

MockFormats returns one *adformat.Format per embedded adformat/examples/*.yaml sample (banner, banner_fixed, popunder, native, video_preroll, push_ad, playable, multiscreen), decoded and Validate()-checked once at call time. IDs are reassigned sequentially (1..N) so the returned slice can be fed straight into adformat.NewSimpleAccessor without collisions — two of the embedded examples intentionally reuse id: 1 in their own YAML file, since each is written as a standalone, independent example.

Panics on decode/validation failure, same convention as the old MockFormats() — these are compile-time-known fixtures, a failure here means adformat/examples itself is broken, not bad runtime input.

func NewAccessor

func NewAccessor() *adformat.SimpleAccessor

NewAccessor builds a ready-to-use adformat.SimpleAccessor over MockFormats(), for tests that need a working Accessor rather than a bare format list.

Types

This section is empty.

Jump to

Keyboard shortcuts

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