jiramock

package
v0.56.0 Latest Latest
Warning

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

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

Documentation

Overview

Package jiramock provides a stateful mock Jira REST API server for behaviour tests. The mock implements the endpoints that jira.LiveClient calls, backed by in-memory state that step definitions manipulate between requests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type State

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

State holds the mutable mock data. All methods are safe for concurrent use.

func NewServer

func NewServer() (*httptest.Server, *State)

NewServer creates a mock Jira REST API server and returns the httptest server and its backing state. The caller should defer srv.Close().

func (*State) AddComment

func (s *State) AddComment(issueKey, body string)

AddComment appends a comment to the given issue. The comment is authored by a canned human user (not a bot).

func (*State) AddCommentFromActor added in v0.36.0

func (s *State) AddCommentFromActor(issueKey, body, accountID, displayName string)

AddCommentFromActor appends a comment to the given issue, authored by the given account. Used to test role resolution for actors other than the default canned commenter.

func (*State) AddCommentFromActorAt added in v0.54.0

func (s *State) AddCommentFromActorAt(issueKey, body, accountID, displayName string, at time.Time)

AddCommentFromActorAt is AddCommentFromActor with an explicit creation time. Tests that run several poll cycles use it to place each comment before the poller's change-detection safety margin and after the previous cycle's checkpoint.

func (*State) AddIssue

func (s *State) AddIssue(key string, labels []string)

AddIssue inserts an issue with the given key and labels. A synthetic numeric ID and timestamp are assigned automatically. An issue without labels is served with an empty list, as Jira Cloud was observed serving it (checked 2026-11-01).

func (*State) AddLabelChange

func (s *State) AddLabelChange(issueKey, label string)

AddLabelChange appends a changelog entry representing a label addition and updates the issue's label list.

func (*State) AddLabelChangeAt added in v0.54.0

func (s *State) AddLabelChangeAt(issueKey, label string, at time.Time)

AddLabelChangeAt is AddLabelChange with an explicit changelog time.

func (*State) Labels added in v0.56.0

func (s *State) Labels(issueKey string) []string

Labels returns the issue's current label list.

func (*State) SetIssueID added in v0.56.0

func (s *State) SetIssueID(key, id string) bool

SetIssueID replaces the synthetic numeric ID of an issue added with AddIssue, so a test can serve an issue whose ID fullsend cannot map. It reports whether the issue exists.

func (*State) SetIssueLabels added in v0.56.0

func (s *State) SetIssueLabels(issueKey string, labels []string)

SetIssueLabels replaces an issue's label list without recording a changelog entry. Scenarios that need a large label state (for example the dispatch transport's labels bound) use it to place the labels at issue creation time rather than emitting one label-change event per label.

func (*State) SetRoleGroup added in v0.36.0

func (s *State) SetRoleGroup(roleName, groupID string)

SetRoleGroup registers a project role as backed by the given group ID, in addition to the canned "Developers" role (whose direct users are commenter-001 and changer-001). Backs GET /project/{key}/role[/{id}] with a group-actor role, for testing per-actor group-based role resolution (GetProjectRoleActors + GetUserGroups) end-to-end.

func (*State) SetUserGroups added in v0.36.0

func (s *State) SetUserGroups(accountID string, groupIDs ...string)

SetUserGroups registers the groups a Jira user belongs to, backing GET /user/groups for per-actor role resolution.

Jump to

Keyboard shortcuts

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