testutils

package
v1.0.0-beta.83 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertGrantsEqual

func AssertGrantsEqual(t *testing.T, expected, actual credit.Grant)

func CreateFeature

func CreateFeature(t *testing.T, connector credit.Connector, feature credit.Feature) credit.Feature

func RemoveTimestampsFromBalance

func RemoveTimestampsFromBalance(balance credit.Balance) credit.Balance

func RemoveTimestampsFromFeatureBalances

func RemoveTimestampsFromFeatureBalances(featureBalances []credit.FeatureBalance) []credit.FeatureBalance

func RemoveTimestampsFromGrant

func RemoveTimestampsFromGrant(g credit.Grant) credit.Grant

func RemoveTimestampsFromGrantBalances

func RemoveTimestampsFromGrantBalances(grantBalances []credit.GrantBalance) []credit.GrantBalance

func RemoveTimestampsFromGrants

func RemoveTimestampsFromGrants(gs []credit.Grant) []credit.Grant

Types

type MockStreamingConnector

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

func (*MockStreamingConnector) AddRow

func (m *MockStreamingConnector) AddRow(meterSlug string, row models.MeterQueryRow)

func (*MockStreamingConnector) AddSimpleEvent

func (m *MockStreamingConnector) AddSimpleEvent(meterSlug string, value float64, at time.Time)

func (*MockStreamingConnector) CreateMeter

func (m *MockStreamingConnector) CreateMeter(ctx context.Context, namespace string, meter *models.Meter) error

func (*MockStreamingConnector) DeleteMeter

func (m *MockStreamingConnector) DeleteMeter(ctx context.Context, namespace string, meterSlug string) error

func (*MockStreamingConnector) ListEvents

func (m *MockStreamingConnector) ListEvents(ctx context.Context, namespace string, params streaming.ListEventsParams) ([]api.IngestedEvent, error)

func (*MockStreamingConnector) ListMeterSubjects

func (m *MockStreamingConnector) ListMeterSubjects(ctx context.Context, namespace string, meterSlug string, from *time.Time, to *time.Time) ([]string, error)

func (*MockStreamingConnector) QueryMeter

func (m *MockStreamingConnector) QueryMeter(ctx context.Context, namespace string, meterSlug string, params *streaming.QueryParams) ([]models.MeterQueryRow, error)

Returns the result query set for the given params. If the query set is not found, it will try to approximate the result by aggregating the simple events

func (*MockStreamingConnector) SetSimpleEvents

func (m *MockStreamingConnector) SetSimpleEvents(meterSlug string, fn func(events []SimpleEvent) []SimpleEvent)

type MockStreamingConnectorParams

type MockStreamingConnectorParams struct {
	DefaultHighwatermark time.Time
}

type SimpleEvent

type SimpleEvent struct {
	MeterSlug string
	Value     float64
	Time      time.Time
}

Jump to

Keyboard shortcuts

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