gitest

package module
v0.0.0-...-64f86d3 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2016 License: MIT Imports: 17 Imported by: 0

README

Gitest

Build Status

A mock GIT server for running git clone in your app's tests without relying on the network

Usage

server, err := gitest.NewServer("basic")
if err != nil {
  log.Fatalf(err)
}
defer server.Close()

tempDir, err := ioutil.TempDir("", "git_repository")
if err != nil {
  log.Fatalf(err)
}

c := exec.Command("git", "clone", fmt.Sprintf("%s/%s.git", server.URL, server.ValidRepo), tempDir)
err = c.Run()
if err != nil {
  log.Fatalf(err)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

type Server struct {
	*httptest.Server

	ValidRepo      string
	NotAllowedRepo string
	// contains filtered or unexported fields
}

Server is an HTTP listener able to respond to git endpoints

func NewServer

func NewServer(template string) (*Server, error)

NewServer creates a new Server object

func NewUnstartedServer

func NewUnstartedServer(template string) (*Server, error)

NewUnstartedServer creates a new server but doesn't start it

func (*Server) Handler

func (s *Server) Handler() *pat.PatternServeMux

Handler is all the http routes required

Jump to

Keyboard shortcuts

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