things

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: MIT Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package things is an offline stand-in for a FastAPI-style REST API: an OpenAPI 3.1 document (Spec) and an in-memory server that answers it. The OpenAPI generator is designed and tested against the pair.

The server does what the spec says, and two things it doesn't, the way real servers drift from their specs:

  • Undocumented filters: `name__icontains` and `description__icontains` on /things, `name__icontains` on /owners.
  • Refused sorts: ThingOrder lists `status` and `-status`; asking for either answers 400 {"detail": "..."}.

Every route but the spec itself needs `Authorization: Bearer <Token>`.

Index

Constants

View Source
const Token = "fixture-token"

Token is the bearer token the server accepts.

Variables

View Source
var EventEvery = time.Second

EventEvery is how often /events sends a frame.

View Source
var RefusedOrders = []string{"status", "-status"}

RefusedOrders are the ThingOrder values the server answers with a 400.

View Source
var Spec []byte

Spec is the OpenAPI document, as YAML.

View Source
var Statuses = []string{"active", "pending", "failed", "archived"}

Statuses are ThingStatus's values, in the spec's order.

Functions

This section is empty.

Types

type Labels

type Labels struct {
	Team *string `json:"team"`
	Env  *string `json:"env"`
}

type Owner

type Owner struct {
	ID    int    `json:"id"`
	Name  string `json:"name"`
	Email string `json:"email"`
}

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server is the stub. Each New starts from the same seed, so tests can rely on ids and counts; writes change only that Server.

func New

func New() *Server

New returns a seeded Server.

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Thing

type Thing struct {
	ID          int       `json:"id"`
	Name        string    `json:"name"`
	Status      string    `json:"status"`
	Size        int       `json:"size"`
	OwnerID     int       `json:"owner_id"`
	Tags        []string  `json:"tags"`
	Labels      Labels    `json:"labels"`
	Description *string   `json:"description"`
	CreatedAt   time.Time `json:"created_at"`
}

Directories

Path Synopsis
Command thingsd serves the things fixture, for running a generated config against it by hand:
Command thingsd serves the things fixture, for running a generated config against it by hand:

Jump to

Keyboard shortcuts

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