testserver

package
v0.8.4 Latest Latest
Warning

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

Go to latest
Published: May 10, 2024 License: MPL-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package testserver provides fake Terramate Cloud endpoints for testing purposes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DisableEndpoints added in v0.4.4

func DisableEndpoints(paths ...string) map[string]bool

DisableEndpoints the provided path endpoints.

func EnableAllConfig

func EnableAllConfig() map[string]bool

EnableAllConfig returns a map that enables all cloud endpoints.

func GetCommit added in v0.5.4

func GetCommit(store *cloudstore.Data, w http.ResponseWriter, _ *http.Request, _ httprouter.Params)

GetCommit returns a commit. GitHub API docs: https://docs.github.com/rest/commits/commits#get-a-commit

func GetDeploymentLogs added in v0.4.4

func GetDeploymentLogs(store *cloudstore.Data, w http.ResponseWriter, _ *http.Request, p httprouter.Params)

GetDeploymentLogs is the GET /deployments/.../logs handler.

func GetDeploymentLogsEvents added in v0.4.4

func GetDeploymentLogsEvents(store *cloudstore.Data, w http.ResponseWriter, _ *http.Request, p httprouter.Params)

GetDeploymentLogsEvents is the SSE GET /deployments/.../logs handler.

func GetDeployments added in v0.4.4

func GetDeployments(store *cloudstore.Data, w http.ResponseWriter, _ *http.Request, p httprouter.Params)

GetDeployments is the GET /deployments handler.

func GetDrift added in v0.4.4

func GetDrift(store *cloudstore.Data, w http.ResponseWriter, _ *http.Request, params httprouter.Params)

GetDrift implements the /v1/drifts/:orguuid/:stackid/:driftid endpoint.

func GetDrifts added in v0.4.4

func GetDrifts(store *cloudstore.Data, w http.ResponseWriter, _ *http.Request, p httprouter.Params)

GetDrifts implements the GET /drifts/:orguuid endpoint. Note: this is not a real endpoint.

func GetMemberships added in v0.4.4

func GetMemberships(store *cloudstore.Data, w http.ResponseWriter, r *http.Request, _ httprouter.Params)

GetMemberships is the testserver GET /memberships handler.

func GetPreview added in v0.5.4

func GetPreview(store *cloudstore.Data, w http.ResponseWriter, _ *http.Request, p httprouter.Params)

GetPreview returns details about a preview. This is a convenience endpoint for asserting the required state in tests (it does not actually exist in the TMC API).

func GetPullRequest added in v0.5.4

func GetPullRequest(store *cloudstore.Data, w http.ResponseWriter, _ *http.Request, _ httprouter.Params)

GetPullRequest returns a pull request. GitHub API docs: https://docs.github.com/rest/pulls/pulls#get-a-pull-request

func GetStackDrifts added in v0.4.4

func GetStackDrifts(store *cloudstore.Data, w http.ResponseWriter, r *http.Request, params httprouter.Params)

GetStackDrifts implements the /v1/stacks/:orguuid/:stackid/drifts endpoint.

func GetStacks added in v0.4.4

func GetStacks(store *cloudstore.Data, w http.ResponseWriter, r *http.Request, params httprouter.Params)

GetStacks is the GET /stacks handler.

func GetUsers added in v0.4.4

func GetUsers(store *cloudstore.Data, w http.ResponseWriter, r *http.Request, _ httprouter.Params)

GetUsers implements the /v1/users endpoint.

func GetWellKnown added in v0.4.4

func GetWellKnown(store *cloudstore.Data, w http.ResponseWriter, _ *http.Request, _ httprouter.Params)

GetWellKnown implements the /.well-known/cli.json endpoint.

func ListCheckRunsForRef added in v0.5.4

func ListCheckRunsForRef(_ *cloudstore.Data, w http.ResponseWriter, _ *http.Request, _ httprouter.Params)

ListCheckRunsForRef returns a list of check runs for a ref. GitHub API docs: https://docs.github.com/rest/checks/runs#list-check-runs-for-a-git-reference

func ListPullRequestsWithCommit added in v0.5.4

func ListPullRequestsWithCommit(_ *cloudstore.Data, w http.ResponseWriter, _ *http.Request, _ httprouter.Params)

ListPullRequestsWithCommit returns a list of pull requests for a commit. GitHub API docs: https://docs.github.com/rest/commits/commits#list-pull-requests-associated-with-a-commit

func ListReviews added in v0.5.4

func ListReviews(_ *cloudstore.Data, w http.ResponseWriter, _ *http.Request, _ httprouter.Params)

ListReviews returns a list of reviews for a pull request. GitHub API docs: https://docs.github.com/rest/pulls/reviews#list-reviews-for-a-pull-request

func PatchDeployment added in v0.4.4

func PatchDeployment(store *cloudstore.Data, w http.ResponseWriter, r *http.Request, p httprouter.Params)

PatchDeployment is the PATCH /deployments handler.

func PatchStackPreviews added in v0.5.4

func PatchStackPreviews(store *cloudstore.Data, w http.ResponseWriter, r *http.Request, p httprouter.Params)

PatchStackPreviews is the PATCH /v1/stack_previews/:stack_preview_id handler.

func PostDeployment added in v0.4.4

func PostDeployment(store *cloudstore.Data, w http.ResponseWriter, r *http.Request, p httprouter.Params)

PostDeployment is the POST /deployments handler.

func PostDeploymentLogs added in v0.4.4

func PostDeploymentLogs(store *cloudstore.Data, w http.ResponseWriter, r *http.Request, p httprouter.Params)

PostDeploymentLogs is the POST /deployments/.../logs handler.

func PostDrift added in v0.4.4

func PostDrift(store *cloudstore.Data, w http.ResponseWriter, r *http.Request, p httprouter.Params)

PostDrift implements the POST /v1/drifts/:orguuid endpoint.

func PostPreviews added in v0.5.4

func PostPreviews(store *cloudstore.Data, w http.ResponseWriter, r *http.Request, p httprouter.Params)

PostPreviews is the POST /v1/previews handler.

func PostStackPreviewsLogs added in v0.5.4

func PostStackPreviewsLogs(store *cloudstore.Data, w http.ResponseWriter, r *http.Request, p httprouter.Params)

PostStackPreviewsLogs is the POST /v1/stack_previews/:stack_preview_id/logs handler.

func PullRequestIsMerged added in v0.5.4

func PullRequestIsMerged(_ *cloudstore.Data, w http.ResponseWriter, _ *http.Request, _ httprouter.Params)

PullRequestIsMerged returns whether a pull request is merged. GitHub API docs: https://docs.github.com/rest/pulls/pulls#check-if-a-pull-request-has-been-merged

func PutStack added in v0.4.4

func PutStack(store *cloudstore.Data, w http.ResponseWriter, r *http.Request, p httprouter.Params)

PutStack is the PUT /stacks handler.

func Router

func Router(store *cloudstore.Data) *httprouter.Router

Router returns the default fake cloud router.

func RouterAdd added in v0.4.2

func RouterAdd(store *cloudstore.Data, router *httprouter.Router, enabled map[string]bool)

RouterAdd enables endpoints in an existing router.

func RouterAddCustoms added in v0.4.2

func RouterAddCustoms(router *httprouter.Router, store *cloudstore.Data, custom Custom)

RouterAddCustoms add custom routes to the fake server. This is used by very specific test cases which requires injection of custom errors in the server.

func RouterWith

func RouterWith(store *cloudstore.Data, enabled map[string]bool) *httprouter.Router

RouterWith returns the testserver router configuration only for the enabled endpoints.

Types

type Custom added in v0.4.2

type Custom struct {
	Routes map[string]Route
}

Custom declares a custom server config.

type Handler added in v0.4.4

type Handler func(store *cloudstore.Data, w http.ResponseWriter, r *http.Request, p httprouter.Params)

Handler is the testserver handler interface.

type Route added in v0.4.2

type Route struct {
	Path    string
	Handler Handler
}

Route declares an HTTP route.

Directories

Path Synopsis
Package cloudstore provides the in-memory store used by the fake Terramate Cloud server.
Package cloudstore provides the in-memory store used by the fake Terramate Cloud server.
cmd
testserver
Package main implements the cloudmock service.
Package main implements the cloudmock service.

Jump to

Keyboard shortcuts

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