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 ¶
- Variables
- func BoolPtr(b bool) *bool
- func DaysAgo(n int) time.Time
- func DaysFromNow(n int) time.Time
- func HoursAgo(n int) time.Time
- func HoursFromNow(n int) time.Time
- func Int64Ptr(i int64) *int64
- func IntPtr(i int) *int
- func MinutesAgo(n int) time.Time
- func MustMarshalJSON(v interface{}) []byte
- func MustMarshalJSONRaw(v interface{}) json.RawMessage
- func MustMarshalJSONString(v interface{}) string
- func NewRandomUUID() uuid.UUID
- func ParseTime(s string) time.Time
- func ParseUUID(s string) uuid.UUID
- func RelativeTime(d time.Duration) time.Time
- func SampleAcknowledgedAlert() client.Alert
- func SampleActiveAlert() client.Alert
- func SampleAdminMember() client.TeamMember
- func SampleAlertList() []client.Alert
- func SampleAlertListResponse() client.AlertListResponse
- func SampleAlertStats() client.AlertStats
- func SampleChannelList() []client.Channel
- func SampleChannelListResponse() client.ChannelListResponse
- func SampleDNSProbe() client.Probe
- func SampleDisabledChannel() client.Channel
- func SampleDownProbe() client.Probe
- func SampleEmailChannel() client.Channel
- func SampleHTTPProbe() client.Probe
- func SampleInvitation() client.Invitation
- func SampleInvitationList() []client.Invitation
- func SampleListOrganizationsResponse() client.ListOrganizationsResponse
- func SampleOrganization() client.Organization
- func SampleOrganizationList() []client.Organization
- func SampleOwnerMember() client.TeamMember
- func SamplePagerDutyChannel() client.Channel
- func SamplePausedProbe() client.Probe
- func SamplePingProbe() client.Probe
- func SampleProbeList() []client.Probe
- func SampleProbeListResponse() client.ProbeListResponse
- func SampleRegionListResponse() client.RegionListResponse
- func SampleRegionStatus() client.RegionStatus
- func SampleRegionStatusMaintenance() client.RegionStatus
- func SampleRegions() map[string][]client.Region
- func SampleRegularMember() client.TeamMember
- func SampleResolvedAlert() client.Alert
- func SampleSecondOrganization() client.Organization
- func SampleSlackChannel() client.Channel
- func SampleTCPProbe() client.Probe
- func SampleTeamMemberList() []client.TeamMember
- func SampleTeamMemberListResponse() client.TeamMemberListResponse
- func SampleViewerMember() client.TeamMember
- func SampleWebhookChannel() client.Channel
- func StringPtr(s string) *string
- func TimePtr(t time.Time) *time.Time
- func UUIDPtr(u uuid.UUID) *uuid.UUID
Constants ¶
This section is empty.
Variables ¶
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.
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 ¶
BoolPtr returns a pointer to the given bool. Useful for optional bool fields in API requests/responses.
func DaysFromNow ¶
DaysFromNow returns a time that is n days after BaseTime.
func HoursFromNow ¶
HoursFromNow returns a time that is n hours after BaseTime.
func IntPtr ¶
IntPtr returns a pointer to the given int. Useful for optional int fields in API requests/responses.
func MinutesAgo ¶
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 ¶
NewRandomUUID generates a new random UUID. This is a convenience wrapper around uuid.New().
func ParseTime ¶
ParseTime parses a time string in RFC3339 format. Panics if the time string is invalid - use only in tests.
func RelativeTime ¶
RelativeTime returns a time relative to BaseTime. Positive durations are in the future, negative are in the past.
func SampleAcknowledgedAlert ¶
SampleAcknowledgedAlert returns an acknowledged alert.
func SampleActiveAlert ¶
SampleActiveAlert returns an active (untriggered) alert.
func SampleAdminMember ¶
func SampleAdminMember() client.TeamMember
SampleAdminMember returns a sample team admin.
func SampleAlertList ¶
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 ¶
SampleChannelList returns a list of sample channels.
func SampleChannelListResponse ¶
func SampleChannelListResponse() client.ChannelListResponse
SampleChannelListResponse returns a complete channel list API response.
func SampleDNSProbe ¶
SampleDNSProbe returns a sample DNS resolve probe.
func SampleDisabledChannel ¶
SampleDisabledChannel returns a disabled channel.
func SampleDownProbe ¶
SampleDownProbe returns a probe in DOWN status.
func SampleEmailChannel ¶
SampleEmailChannel returns a sample email notification channel.
func SampleHTTPProbe ¶
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 ¶
SamplePagerDutyChannel returns a sample PagerDuty notification channel.
func SamplePausedProbe ¶
SamplePausedProbe returns a paused probe.
func SamplePingProbe ¶
SamplePingProbe returns a sample Ping probe.
func SampleProbeList ¶
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 ¶
SampleRegions returns regions grouped by continent.
func SampleRegularMember ¶
func SampleRegularMember() client.TeamMember
SampleRegularMember returns a sample regular team member.
func SampleResolvedAlert ¶
SampleResolvedAlert returns a resolved alert.
func SampleSecondOrganization ¶
func SampleSecondOrganization() client.Organization
SampleSecondOrganization returns a second sample organization.
func SampleSlackChannel ¶
SampleSlackChannel returns a sample Slack notification channel.
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 ¶
SampleWebhookChannel returns a sample webhook notification channel.
func StringPtr ¶
StringPtr returns a pointer to the given string. Useful for optional string fields in API requests/responses.
Types ¶
This section is empty.