integrationtest

package
v0.0.0-...-3c969ed Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// DefaultOrgID is the ID of the default organisation in Grafana.
	DefaultOrgID = 1
)

Variables

This section is empty.

Functions

func SkipIfShort

func SkipIfShort(t *testing.T)

Types

type GitHub

type GitHub struct {
	// contains filtered or unexported fields
}

GitHub starts an httptest.Server that emulates the GitHub API. The server responds only to requests for:

  • GET /repos/:owner/:repo/contents/:path - Returns file metadata or 404 if file doesn't exist.
  • PUT /repos/:owner/:repo/contents/:path - Creates or updates files.

The server is automatically stopped by t.Cleanup().

See documentation.

func NewGitHub

func NewGitHub(t testing.TB) *GitHub

NewGitHub creates a new faux GitHub API server.

func (*GitHub) Requests

func (g *GitHub) Requests() map[string][]*http.Request

Requests returns all HTTP requests received by the faux GitHub API server, keyed by "{METHOD} {PATH}".

func (*GitHub) URL

func (g *GitHub) URL() string

URL returns the base URL of the faux GitHub API server.

type Grafana

type Grafana struct {
	// contains filtered or unexported fields
}

func NewGrafana

func NewGrafana(t *testing.T, logConsumers ...testcontainers.LogConsumer) *Grafana

func (*Grafana) AssertDashboardDoesNotExist

func (g *Grafana) AssertDashboardDoesNotExist(t assert.TestingT, apiKey, namespace, name string)

func (*Grafana) AssertDashboardExists

func (g *Grafana) AssertDashboardExists(t assert.TestingT, apiKey, namespace, name string)

func (*Grafana) CreateAPIKey

func (g *Grafana) CreateAPIKey(t *testing.T, name string, orgID int) string

CreateAPIKey creates a Grafana API key with admin permissions using the service account API.

func (*Grafana) CreateDashboard

func (g *Grafana) CreateDashboard(t *testing.T, apiKey, namespace, name string)

CreateDashboard in Grafana using the traditional HTTP API.

func (*Grafana) CreateDashboardWithTags

func (g *Grafana) CreateDashboardWithTags(t *testing.T, apiKey, namespace, name string, tags []string)

CreateDashboardWithTags creates a dashboard in Grafana with the specified tags.

func (*Grafana) CreateOrganisation

func (g *Grafana) CreateOrganisation(t testing.TB, name string) int

CreateOrganisation creates a new organisation in Grafana and returns its ID.

func (*Grafana) Host

func (g *Grafana) Host() string

func (*Grafana) ViewDashboardInUI

func (g *Grafana) ViewDashboardInUI(t testing.TB, apiKey, namespace, name string)

ViewDashboardInUI simulates viewing a dashboard in the Grafana UI by calling the /dto endpoint. When a user views a dashboard in the Grafana web interface, the frontend JavaScript makes an API call to the /dto endpoint to fetch the dashboard data. This method simulates that API call.

type LogEntry

type LogEntry struct {
	Timestamp time.Time
	Message   string
	Labels    map[string]string
}

LogEntry represents a single log entry to be pushed to Loki.

type Loki

type Loki struct {
	// contains filtered or unexported fields
}

func NewLoki

func NewLoki(t *testing.T) *Loki

func (*Loki) Host

func (l *Loki) Host() string

func (*Loki) PushLogs

func (l *Loki) PushLogs(ctx context.Context, logs []LogEntry) error

PushLogs sends logs to Loki via the push API.

Jump to

Keyboard shortcuts

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