helpers

package
v0.0.0-...-06858c0 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package helpers contains functions that help executing tests. The helper functions generally look from the client side - a Poseidon user.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildURL

func BuildURL(parts ...string) string

BuildURL joins multiple route paths.

func CreateTemplateJob

func CreateTemplateJob() (base, job *nomadApi.Job)

func HTTPDelete

func HTTPDelete(url string, body io.Reader) (response *http.Response, err error)

HTTPDelete sends a "Delete" Http Request with body to the passed url.

func HTTPPatch

func HTTPPatch(url, contentType string, body io.Reader) (response *http.Response, err error)

HTTPPatch sends a Patch Http Request with body to the passed url.

func HTTPPostJSON

func HTTPPostJSON(url string, body interface{}) (response *http.Response, err error)

func HTTPPut

func HTTPPut(url string, body io.Reader) (response *http.Response, err error)

func HTTPPutJSON

func HTTPPutJSON(url string, body interface{}) (response *http.Response, err error)

func ReceiveAllWebSocketMessages

func ReceiveAllWebSocketMessages(connection *websocket.Conn) (messages []*dto.WebSocketMessage, err error)

ReceiveAllWebSocketMessages pulls all messages from the websocket connection without sending anything. This function does not return unless the server closes the connection or a readDeadline is set in the WebSocket connection.

func ReceiveNextWebSocketMessage

func ReceiveNextWebSocketMessage(connection *websocket.Conn) (*dto.WebSocketMessage, error)

ReceiveNextWebSocketMessage pulls the next message from the websocket connection. This function does not return unless the server sends a message, closes the connection or a readDeadline is set in the WebSocket connection.

func StartTLSServer

func StartTLSServer(t *testing.T, router *mux.Router) (*httptest.Server, error)

StartTLSServer runs a httptest.Server with the passed mux.Router and TLS enabled.

func WebSocketControlMessages

func WebSocketControlMessages(messages []*dto.WebSocketMessage) (controls []*dto.WebSocketMessage)

WebSocketControlMessages extracts all meta (and exit) messages from the passed messages.

func WebSocketOutputMessages

func WebSocketOutputMessages(messages []*dto.WebSocketMessage) (stdout, stderr string, errors []string)

WebSocketOutputMessages extracts all stdout, stderr and error messages from the passed messages. It is useful since Nomad splits the command output nondeterministic.

Types

This section is empty.

Jump to

Keyboard shortcuts

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