testutil

package
v0.2.0-rc.3 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package testutil provides test fixtures and mock data for StackEye CLI tests. This package contains pre-defined sample data that matches API response shapes, making it easy to write consistent and realistic tests.

Package testutil provides test fixtures and mock data for StackEye CLI tests. This file contains helper functions for creating test data.

Index

Constants

This section is empty.

Variables

View Source
var (
	// Probe UUIDs
	ProbeID1 = uuid.MustParse("11111111-1111-1111-1111-111111111111")
	ProbeID2 = uuid.MustParse("22222222-2222-2222-2222-222222222222")
	ProbeID3 = uuid.MustParse("33333333-3333-3333-3333-333333333333")
	ProbeID4 = uuid.MustParse("44444444-4444-4444-4444-444444444444")

	// Alert UUIDs
	AlertID1 = uuid.MustParse("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa")
	AlertID2 = uuid.MustParse("bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb")
	AlertID3 = uuid.MustParse("cccccccc-cccc-cccc-cccc-cccccccccccc")

	// Channel UUIDs
	ChannelID1 = uuid.MustParse("c1111111-1111-1111-1111-111111111111")
	ChannelID2 = uuid.MustParse("c2222222-2222-2222-2222-222222222222")
	ChannelID3 = uuid.MustParse("c3333333-3333-3333-3333-333333333333")
	ChannelID4 = uuid.MustParse("c4444444-4444-4444-4444-444444444444")

	// Organization UUIDs
	OrgID1 = uuid.MustParse("00000000-0000-0000-0000-000000000001")
	OrgID2 = uuid.MustParse("00000000-0000-0000-0000-000000000002")

	// User UUIDs
	UserID1 = uuid.MustParse("dddddddd-dddd-dddd-dddd-dddddddddddd")
	UserID2 = uuid.MustParse("eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee")
)

Fixed UUIDs for reproducible test assertions. These are valid UUIDv4 values that can be used across tests.

View Source
var (
	// BaseTime is a fixed reference time for tests (2024-01-15 10:30:00 UTC)
	BaseTime = time.Date(2024, 1, 15, 10, 30, 0, 0, time.UTC)

	// TimeOneHourAgo is BaseTime minus 1 hour
	TimeOneHourAgo = BaseTime.Add(-1 * time.Hour)

	// TimeOneDayAgo is BaseTime minus 24 hours
	TimeOneDayAgo = BaseTime.Add(-24 * time.Hour)

	// TimeOneWeekAgo is BaseTime minus 7 days
	TimeOneWeekAgo = BaseTime.Add(-7 * 24 * time.Hour)
)

Fixed timestamps for reproducible test assertions.

Functions

func BoolPtr

func BoolPtr(b bool) *bool

BoolPtr returns a pointer to the given bool. Useful for optional bool fields in API requests/responses.

func DaysAgo

func DaysAgo(n int) time.Time

DaysAgo returns a time that is n days before BaseTime.

func DaysFromNow

func DaysFromNow(n int) time.Time

DaysFromNow returns a time that is n days after BaseTime.

func HoursAgo

func HoursAgo(n int) time.Time

HoursAgo returns a time that is n hours before BaseTime.

func HoursFromNow

func HoursFromNow(n int) time.Time

HoursFromNow returns a time that is n hours after BaseTime.

func Int64Ptr

func Int64Ptr(i int64) *int64

Int64Ptr returns a pointer to the given int64.

func IntPtr

func IntPtr(i int) *int

IntPtr returns a pointer to the given int. Useful for optional int fields in API requests/responses.

func MinutesAgo

func MinutesAgo(n int) time.Time

MinutesAgo returns a time that is n minutes before BaseTime.

func MustMarshalJSON

func MustMarshalJSON(v interface{}) []byte

MustMarshalJSON marshals v to JSON bytes. Panics if marshaling fails - use only in tests.

func MustMarshalJSONRaw

func MustMarshalJSONRaw(v interface{}) json.RawMessage

MustMarshalJSONRaw marshals v to json.RawMessage. Panics if marshaling fails - use only in tests.

func MustMarshalJSONString

func MustMarshalJSONString(v interface{}) string

MustMarshalJSONString marshals v to a JSON string. Panics if marshaling fails - use only in tests.

func NewRandomUUID

func NewRandomUUID() uuid.UUID

NewRandomUUID generates a new random UUID. This is a convenience wrapper around uuid.New().

func ParseTime

func ParseTime(s string) time.Time

ParseTime parses a time string in RFC3339 format. Panics if the time string is invalid - use only in tests.

func ParseUUID

func ParseUUID(s string) uuid.UUID

ParseUUID parses a UUID string. Panics if the UUID is invalid - use only in tests.

func RelativeTime

func RelativeTime(d time.Duration) time.Time

RelativeTime returns a time relative to BaseTime. Positive durations are in the future, negative are in the past.

func SampleAcknowledgedAlert

func SampleAcknowledgedAlert() client.Alert

SampleAcknowledgedAlert returns an acknowledged alert.

func SampleActiveAlert

func SampleActiveAlert() client.Alert

SampleActiveAlert returns an active (untriggered) alert.

func SampleAdminMember

func SampleAdminMember() client.TeamMember

SampleAdminMember returns a sample team admin.

func SampleAlertList

func SampleAlertList() []client.Alert

SampleAlertList returns a list of sample alerts.

func SampleAlertListResponse

func SampleAlertListResponse() client.AlertListResponse

SampleAlertListResponse returns a complete alert list API response.

func SampleAlertStats

func SampleAlertStats() client.AlertStats

SampleAlertStats returns sample alert statistics.

func SampleChannelList

func SampleChannelList() []client.Channel

SampleChannelList returns a list of sample channels.

func SampleChannelListResponse

func SampleChannelListResponse() client.ChannelListResponse

SampleChannelListResponse returns a complete channel list API response.

func SampleDNSProbe

func SampleDNSProbe() client.Probe

SampleDNSProbe returns a sample DNS resolve probe.

func SampleDisabledChannel

func SampleDisabledChannel() client.Channel

SampleDisabledChannel returns a disabled channel.

func SampleDownProbe

func SampleDownProbe() client.Probe

SampleDownProbe returns a probe in DOWN status.

func SampleEmailChannel

func SampleEmailChannel() client.Channel

SampleEmailChannel returns a sample email notification channel.

func SampleHTTPProbe

func SampleHTTPProbe() client.Probe

SampleHTTPProbe returns a sample HTTP probe with default values.

func SampleInvitation

func SampleInvitation() client.Invitation

SampleInvitation returns a sample pending invitation.

func SampleInvitationList

func SampleInvitationList() []client.Invitation

SampleInvitationList returns a list of sample invitations.

func SampleListOrganizationsResponse

func SampleListOrganizationsResponse() client.ListOrganizationsResponse

SampleListOrganizationsResponse returns a complete organizations list API response.

func SampleOrganization

func SampleOrganization() client.Organization

SampleOrganization returns a sample organization.

func SampleOrganizationList

func SampleOrganizationList() []client.Organization

SampleOrganizationList returns a list of sample organizations.

func SampleOwnerMember

func SampleOwnerMember() client.TeamMember

SampleOwnerMember returns a sample team owner.

func SamplePagerDutyChannel

func SamplePagerDutyChannel() client.Channel

SamplePagerDutyChannel returns a sample PagerDuty notification channel.

func SamplePausedProbe

func SamplePausedProbe() client.Probe

SamplePausedProbe returns a paused probe.

func SamplePingProbe

func SamplePingProbe() client.Probe

SamplePingProbe returns a sample Ping probe.

func SampleProbeList

func SampleProbeList() []client.Probe

SampleProbeList returns a list of sample probes for pagination tests.

func SampleProbeListResponse

func SampleProbeListResponse() client.ProbeListResponse

SampleProbeListResponse returns a complete probe list API response.

func SampleRegionListResponse

func SampleRegionListResponse() client.RegionListResponse

SampleRegionListResponse returns a complete region list API response.

func SampleRegionStatus

func SampleRegionStatus() client.RegionStatus

SampleRegionStatus returns a sample region status.

func SampleRegionStatusMaintenance

func SampleRegionStatusMaintenance() client.RegionStatus

SampleRegionStatusMaintenance returns a region in maintenance.

func SampleRegions

func SampleRegions() map[string][]client.Region

SampleRegions returns regions grouped by continent.

func SampleRegularMember

func SampleRegularMember() client.TeamMember

SampleRegularMember returns a sample regular team member.

func SampleResolvedAlert

func SampleResolvedAlert() client.Alert

SampleResolvedAlert returns a resolved alert.

func SampleSecondOrganization

func SampleSecondOrganization() client.Organization

SampleSecondOrganization returns a second sample organization.

func SampleSlackChannel

func SampleSlackChannel() client.Channel

SampleSlackChannel returns a sample Slack notification channel.

func SampleTCPProbe

func SampleTCPProbe() client.Probe

SampleTCPProbe returns a sample TCP probe.

func SampleTeamMemberList

func SampleTeamMemberList() []client.TeamMember

SampleTeamMemberList returns a list of sample team members.

func SampleTeamMemberListResponse

func SampleTeamMemberListResponse() client.TeamMemberListResponse

SampleTeamMemberListResponse returns a complete team member list API response.

func SampleViewerMember

func SampleViewerMember() client.TeamMember

SampleViewerMember returns a sample viewer team member.

func SampleWebhookChannel

func SampleWebhookChannel() client.Channel

SampleWebhookChannel returns a sample webhook notification channel.

func StringPtr

func StringPtr(s string) *string

StringPtr returns a pointer to the given string. Useful for optional string fields in API requests/responses.

func TimePtr

func TimePtr(t time.Time) *time.Time

TimePtr returns a pointer to the given time.Time. Useful for optional timestamp fields.

func UUIDPtr

func UUIDPtr(u uuid.UUID) *uuid.UUID

UUIDPtr returns a pointer to the given UUID.

Types

This section is empty.

Jump to

Keyboard shortcuts

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