v1

package
v0.0.80 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: Apache-2.0 Imports: 15 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 (
	// ErrNotIngeserOverridden is returned when a provider trait is not overridden.
	ErrNotIngeserOverridden = 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 Note that if the `git` ingest type is used, you need to overwrite the ingester in the rule type engine.

func WithHTTP

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

WithHTTP is a functional option to set the HTTP response

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 trait. This is a stub implementation that allows us to instantiate a Git ingester. This will later be overridden by the actual implementation.

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.Result, 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) RegisterEntity

RegisterEntity implements the Provider interface.

func (*TestKit) ReregisterEntity

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

ReregisterEntity implements the Provider 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.Result)

SetIngestResult implements the ResultSink interface

Jump to

Keyboard shortcuts

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