seed

package
v1.23.0 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2026 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Overview

Package seed provides deterministic test data seeding for PeeringDB entity types. It creates well-known entities with fixed IDs so that any test package can populate a database with realistic data via a single function call.

Index

Constants

View Source
const (
	// IxLanGatedID is the ixlan row with ixf_ixp_member_list_url_visible
	// set to "Users" (URL populated). Anon callers must NOT see the URL;
	// Users-tier callers MUST see it.
	IxLanGatedID = 100
	// IxLanPublicID is the ixlan row with ixf_ixp_member_list_url_visible
	// set to "Public" (URL populated). All callers (Public and Users
	// tiers) MUST see the URL — proves the helper does not over-redact.
	IxLanPublicID = 101
)

Deterministic ixlan IDs for the field-level privacy seed fixture. The field-privacy E2E imports these constants to target the gated vs always-admit rows precisely.

Variables

View Source
var Timestamp = time.Date(2024, 1, 1, 0, 0, 0, 0, time.UTC)

Timestamp is the deterministic timestamp used for all seed entity created/updated fields.

Functions

This section is empty.

Types

type Result

type Result struct {
	Org       *ent.Organization
	Network   *ent.Network
	Network2  *ent.Network // second network, only in Full
	IX        *ent.InternetExchange
	Facility  *ent.Facility
	Facility2 *ent.Facility // campus-assigned facility, only in Full
	Campus    *ent.Campus
	Carrier   *ent.Carrier
	IxLan     *ent.IxLan
	// IxLanPublic is the second ixlan (id=101) seeded by Full: URL
	// populated with ixf_ixp_member_list_url_visible="Public". Two rows
	// are required so the field-privacy E2E coverage can exercise both
	// the always-admit (Public) path and the gated (Users) path against
	// real seed data.
	IxLanPublic     *ent.IxLan
	IxPrefix        *ent.IxPrefix
	NetworkIxLan    *ent.NetworkIxLan
	NetworkFacility *ent.NetworkFacility
	IxFacility      *ent.IxFacility
	CarrierFacility *ent.CarrierFacility
	Poc             *ent.Poc
	// UsersPoc is a visible="Users" POC attached to r.Network. Created via
	// privacy.DecisionContext(Allow) because ent Policy() admits writes
	// identically to reads — future mutation policies could reject it.
	// ID 9000 (reserved band 9000-9099 for Users-tier seed rows).
	UsersPoc *ent.Poc
	// UsersPoc2 is a visible="Users" POC attached to r.Network2. ID 9001.
	UsersPoc2 *ent.Poc
	// AllPocs exposes every POC created (Public + Users) in deterministic
	// order: r.Poc, r.UsersPoc, r.UsersPoc2. Consumers that iterate POCs
	// for assertions (list-count tests) should use this slice.
	AllPocs     []*ent.Poc
	AllNetworks []*ent.Network // all created networks (for Networks())
}

Result holds typed references to all entities created by seed functions.

func Full

func Full(tb testing.TB, client *ent.Client) *Result

Full creates one entity of each of the 13 PeeringDB types plus a second Network and a campus-assigned Facility. It uses deterministic IDs matching the legacy seedAllTestData pattern for backward compatibility.

Jump to

Keyboard shortcuts

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