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

glabtest

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package glabtest provides an in-memory GitLab that answers `glab api` calls.

Index

Constants

This section is empty.

Variables

View Source
var Repo = protocol.Repo{Host: "gitlab.example", Path: projectPath}

Repo is the repository the fake answers for.

Functions

This section is empty.

Types

type Call

type Call struct {
	Method, Endpoint string
	Fields           map[string]string
}

Call is one recorded glab invocation.

type GitLab

type GitLab struct {
	MRs map[int]*glab.MR

	Calls []Call
	// Fail makes the next call matching "METHOD endpoint-suffix" fail.
	Fail map[string]error
	// OnMerge runs when an MR is merged, e.g. to update the git remote.
	OnMerge func(mr *glab.MR, squash bool) error
	// Project is returned by GET projects/:project.
	Project glab.ProjectInfo
	// PendingPolls makes a merged MR report "opened" with auto-merge set for
	// this many GETs before it shows as merged, like a running pipeline.
	PendingPolls int

	// Protected lists protected branches; "main" is the default branch.
	Protected map[string]bool
	// contains filtered or unexported fields
}

GitLab is a fake project's merge requests.

func New

func New() *GitLab

New returns an empty fake.

func (*GitLab) Add

func (g *GitLab) Add(mr glab.MR) *glab.MR

Add inserts an MR directly and returns it.

func (*GitLab) CallsTo

func (g *GitLab) CallsTo(substr string) []Call

CallsTo returns recorded calls whose "METHOD endpoint" contains substr.

func (*GitLab) Client

func (g *GitLab) Client() *glab.Client

Client returns a glab.Client backed by the fake.

func (*GitLab) Run

func (g *GitLab) Run(args ...string) ([]byte, error)

Run implements glab.Runner for `glab api` invocations.

Jump to

Keyboard shortcuts

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