v1

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package v1 contains the v1 version of the testkit package. This is meant to aid developers in testing out minder rule types and other components.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrIngestUnimplemented is returned when the ingester is not implemented
	ErrIngestUnimplemented = errors.New("ingester not implemented")
)
View Source
var (
	// ErrNotIngesterOverridden is returned when a provider trait is not overridden.
	ErrNotIngesterOverridden = errors.New("ingester not overridden")
)

Functions

This section is empty.

Types

type Option

type Option func(*TestKit)

Option is a functional option type for TestKit

func WithGitDir

func WithGitDir(dir string) Option

WithGitDir is a functional option to set the git directory. It eagerly creates an osfs.Filesystem rooted at dir.

func WithGitFiles added in v0.2.0

func WithGitFiles(files map[string]string) Option

WithGitFiles is a functional option to configure the TestKit with a mocked in-memory filesystem for git ingestion testing. Each key is a file path and each value is the file content.

func WithHTTP

func WithHTTP(status int, body []byte, headers map[string]string) Option

WithHTTP is a functional option to set the HTTP response

func WithHandlerFunc added in v0.2.0

func WithHandlerFunc(hf http.HandlerFunc) Option

WithHandlerFunc is a functional option to configure the TestKit to use a specific Handler

type TestKit

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

TestKit implements a set of interfaces for testing purposes. e.g. for testing rule types.

func NewTestKit

func NewTestKit(opts ...Option) *TestKit

NewTestKit creates a new TestKit

func (*TestKit) CanImplement

func (*TestKit) CanImplement(_ minderv1.ProviderType) bool

CanImplement implements the Provider interface. It returns true since we don't have any restrictions on the provider.

func (*TestKit) Clone

func (*TestKit) Clone(_ context.Context, _ string, _ string) (*git.Repository, error)

Clone implements the Git interface. TestKit relies on fakeGit and Ingest for filesystem operations.

func (*TestKit) CreationOptions added in v0.1.2

func (*TestKit) CreationOptions(_ minderv1.Entity) *provv1.EntityCreationOptions

CreationOptions implements the Provider interface.

func (*TestKit) DeregisterEntity

func (*TestKit) DeregisterEntity(_ context.Context, _ minderv1.Entity, _ *properties.Properties) error

DeregisterEntity implements the Provider interface.

func (*TestKit) Do

func (tk *TestKit) Do(ctx context.Context, req *http.Request) (*http.Response, error)

Do executes an HTTP request.

func (*TestKit) FetchAllProperties

FetchAllProperties implements the Provider interface.

func (*TestKit) FetchProperty

FetchProperty implements the Provider interface.

func (*TestKit) GetBaseURL

func (*TestKit) GetBaseURL() string

GetBaseURL implements the REST interface.

func (*TestKit) GetConfig

func (*TestKit) GetConfig() protoreflect.ProtoMessage

GetConfig returns the config for the ingester

func (*TestKit) GetEntityName

func (*TestKit) GetEntityName(_ minderv1.Entity, _ *properties.Properties) (string, error)

GetEntityName implements the Provider interface.

func (*TestKit) GetType

func (*TestKit) GetType() string

GetType returns the type of the ingester

func (*TestKit) Ingest

func (tk *TestKit) Ingest(
	ctx context.Context, ent protoreflect.ProtoMessage, params map[string]any,
) (*interfaces.Ingested, error)

Ingest is a stub implementation of the ingester

func (*TestKit) NewRequest

func (*TestKit) NewRequest(method, url string, body any) (*http.Request, error)

NewRequest implements the REST interface.

func (*TestKit) PropertiesToProtoMessage

func (*TestKit) PropertiesToProtoMessage(_ minderv1.Entity, _ *properties.Properties) (protoreflect.ProtoMessage, error)

PropertiesToProtoMessage implements the Provider interface.

func (*TestKit) ProviderClassInfo added in v0.2.0

func (*TestKit) ProviderClassInfo() *minderv1.ProviderClassInfo

ProviderClassInfo implements the Provider interface.

func (*TestKit) RegisterEntity

func (*TestKit) RegisterEntity(_ context.Context, _ minderv1.Entity, props *properties.Properties,
) (*properties.Properties, error)

RegisterEntity implements the Provider interface.

func (*TestKit) RoundTrip added in v0.2.0

func (tk *TestKit) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip implements the http.RoundTripper interface.

func (*TestKit) ShouldOverrideIngest

func (tk *TestKit) ShouldOverrideIngest() bool

ShouldOverrideIngest returns true if the ingester should override the ingest

func (*TestKit) SupportsEntity

func (*TestKit) SupportsEntity(_ minderv1.Entity) bool

SupportsEntity implements the Provider interface.

type VoidResultSink

type VoidResultSink struct{}

VoidResultSink is a result sink that does nothing

func NewVoidResultSink

func NewVoidResultSink() *VoidResultSink

NewVoidResultSink creates a new void result sink

func (VoidResultSink) SetIngestResult

func (VoidResultSink) SetIngestResult(_ *interfaces.Ingested)

SetIngestResult implements the ResultSink interface

Jump to

Keyboard shortcuts

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