resolvertest

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package resolvertest provides an in-memory file tree for include resolution tests, so tests never touch disk. One seed serves every suite:

resolvertest.Seed("/base/shared.thrift")        // existence only
resolver.New(paths, resolver.WithFS(tree))      // fs.FS shape
resolver.New(paths, resolver.WithChecker(tree)) // Checker shape
store.NewMemFS(tree.URIs())                     // FileSource shape

The production path stays string paths end to end; URIs converts keys for FileSource-based suites only.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Map

type Map map[string][]byte

Map is an in-memory file tree keyed by path. Lookups are exact matches, so seed the same form the resolver produces (absolute paths joined from include roots). The zero value is an empty tree, ready for existence checks.

func Seed

func Seed(paths ...string) Map

Seed builds a Map from paths with no content. Include resolution only probes existence, so content is irrelevant; tests asserting on content seed Map literals directly.

func (Map) Exists

func (m Map) Exists(ctx context.Context, path string) bool

Exists reports whether path is a seeded file, without reading content. It satisfies the resolver's existence checker contract.

func (Map) Open

func (m Map) Open(name string) (fs.File, error)

Open implements fs.FS by exact path match.

func (Map) Stat

func (m Map) Stat(name string) (fs.FileInfo, error)

Stat implements fs.StatFS by exact path match, so fs.Stat prefers it over opening the file.

func (Map) URIs

func (m Map) URIs() map[uri.URI][]byte

URIs converts the tree to a FileSource seed: each path becomes its file URI with the same content. The content slices are shared with the Map, so tests must not mutate them.

Jump to

Keyboard shortcuts

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