lacework

package
v1.50.0 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Mock

type Mock struct {
	Mux        *http.ServeMux
	Server     *httptest.Server
	ApiVersion string
}

Mock is a quick HTTP server that can be used to mock a Lacework API server, you can use it to avoid using a real server in our unit tests

A simple usage:

func TestSomethingNew(t *testing.T) {
    fakeServer := lacework.NewServer()
    fakeServer.MockToken("TOKEN")
    defer fakeServer.Close()

    // Make sure to pass the fake API server URL
    c, err := api.NewClient("test", api.WithURL(fakeServer.URL()))
    if assert.Nil(t, err) {
    	// The client c is ready to be used
    }
}

func MockServer

func MockServer() *Mock

MockServer returns a new mocked http server with a mutex

func MockUnstartedServer added in v1.17.0

func MockUnstartedServer() *Mock

func (Mock) Close

func (m Mock) Close()

func (*Mock) MockAPI

func (m *Mock) MockAPI(p string, handler func(http.ResponseWriter, *http.Request))

MockAPI will mock the api path inside the server mutex with the provided handler function

func (*Mock) MockToken

func (s *Mock) MockToken(token string)

func (Mock) URL

func (m Mock) URL() string

Jump to

Keyboard shortcuts

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