mockserver

package
v0.0.0-...-4362f39 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package mockserver aims at mocking the API for unit tests. Call the instance with GetServer, add endpoints with AddJSONHandler.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddJSONHandler

func AddJSONHandler(t *testing.T, res MockJSONResponse)

AddJSONHandler adds a mocked handler corresponding to the MockJsonResponse.

func GetServer

func GetServer() *httptest.Server

GetServer returns the httptest Server used to fake the API.

Types

type MockJSONResponse

type MockJSONResponse struct {
	Path         string
	ResponseCode int
	FilePath     string
	QueryParams  *url.Values
}

MockJSONResponse represents a fake http response with

  • a response status code
  • a user-provided json file path containing the payload.

Jump to

Keyboard shortcuts

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