gitserver

package
v0.21.4 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package gitserver is a stand-in git remote for tests that must prove a token reached the forge it belongs to, without a network or a real forge.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Always added in v0.21.4

func Always(int, *http.Request) bool

Always fails every request.

func FirstN added in v0.21.4

func FirstN(n int) func(int, *http.Request) bool

FirstN fails the first n requests.

Types

type Flaky added in v0.21.4

type Flaky struct {
	// Fails is asked of each request, numbered from 1, before it is served.
	Fails func(n int, r *http.Request) bool

	// Status is the answer a failed request gets.
	Status int
	// contains filtered or unexported fields
}

Flaky serves a repository on disk over git's smart HTTP, and answers Status instead to each request Fails picks.

The git side is go-git's own server rather than git http-backend, which Wolfi's git, the CI image's, does not ship. A shallow clone gets the whole history.

func (*Flaky) Requests added in v0.21.4

func (f *Flaky) Requests() int

Requests is how many requests have arrived, served or failed.

func (*Flaky) Serve added in v0.21.4

func (f *Flaky) Serve(t *testing.T, dir string) string

Serve starts serving dir, a bare repository or a working one, for the length of the test and returns its clone URL. Pushes update refs only, never a working tree.

type Server

type Server struct {
	// Origin is the server's scheme, host and port.
	Origin string
	// contains filtered or unexported fields
}

Server refuses every request with a 401, and records what each one presented.

func New

func New(t *testing.T) *Server

New starts a Server for the length of the test.

func (*Server) Received

func (s *Server) Received(token string) bool

Received reports whether a request presented token as its password.

Jump to

Keyboard shortcuts

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