Help us shape the future of Go! Take the 2026 Go Developer Survey

fakelinear

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package fakelinear is a deterministic, in-memory fake of the Linear GraphQL API subset used by connectors/linear. Requests are matched loosely by the root field name of the query or mutation; variables carry all inputs.

Supported root fields: viewer, project, projects, projectCreate, issue, issues, searchIssues, issueCreate, issueUpdate, commentCreate, comments.

Test control:

GET  /_test/state  projects, issues and comments
POST /_test/fail   {operation, mode, count}; mode is
                   "drop_response_after_commit" (apply, then close the connection),
                   "error" (GraphQL error, not applied),
                   "rate_limited" (HTTP 429, not applied) or
                   "server_error" (HTTP 500, not applied)
POST /_test/reset  clear records and failures

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RootField

func RootField(query string) string

RootField returns the first selected field of a GraphQL document.

Types

type Comment

type Comment struct {
	ID        string    `json:"id"`
	IssueID   string    `json:"issue_id"`
	Body      string    `json:"body"`
	URL       string    `json:"url"`
	Author    string    `json:"author,omitempty"`
	CreatedAt time.Time `json:"created_at"`
}

Comment is a stored comment.

type Issue

type Issue struct {
	ID          string `json:"id"`
	Identifier  string `json:"identifier"`
	Title       string `json:"title"`
	Description string `json:"description"`
	URL         string `json:"url"`
	Priority    int    `json:"priority"`
	TeamID      string `json:"team_id"`
	ProjectID   string `json:"project_id,omitempty"`
	StateID     string `json:"state_id,omitempty"`
	AssigneeID  string `json:"assignee_id,omitempty"`
}

Issue is a stored issue.

type Options

type Options struct {
	// APIKey, when set, must equal the Authorization header (with or without
	// "Bearer "). Otherwise any non-empty value is accepted.
	APIKey string
	// OrganizationID is the viewer's organisation id. Default org-fake.
	OrganizationID string
	// Teams maps team id to key. Default: team-eng ENG.
	Teams map[string]string
}

Options configure the fake.

type Project

type Project struct {
	ID          string   `json:"id"`
	Name        string   `json:"name"`
	Description string   `json:"description"`
	Content     string   `json:"content"`
	URL         string   `json:"url"`
	State       string   `json:"state"`
	TeamIDs     []string `json:"team_ids"`
}

Project is a stored project.

type Server

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

Server is the fake. It implements http.Handler.

func New

func New(opts Options) *Server

New creates the fake.

func (*Server) AddComment added in v0.2.0

func (s *Server) AddComment(issueID, author, body string) (Comment, error)

AddComment adds a comment as a human would in the Linear UI.

func (*Server) Fail

func (s *Server) Fail(operation, mode string, count int)

Fail makes the next count requests for a root field fail with mode.

func (*Server) Reset

func (s *Server) Reset()

Reset clears records and failure rules.

func (*Server) ServeHTTP

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

ServeHTTP implements http.Handler.

func (*Server) SetKeys added in v0.2.0

func (s *Server) SetKeys(keys []string)

SetKeys replaces the accepted API keys, as when a key is rotated or revoked. An empty list restores Options.APIKey.

func (*Server) State

func (s *Server) State() State

State returns a copy of all records.

type State

type State struct {
	Projects []Project `json:"projects"`
	Issues   []Issue   `json:"issues"`
	Comments []Comment `json:"comments"`
}

State is the full fake state.

type Team

type Team struct {
	ID  string `json:"id"`
	Key string `json:"key"`
}

Team is a Linear team.

Jump to

Keyboard shortcuts

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