middleware

package
v1.21.0 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func JSONResponse added in v1.3.0

func JSONResponse(t *testing.T, statusCode int, body any) http.HandlerFunc

JSONResponse creates an HTTP handler that responds with the given status code and JSON body

func RunTestCases

func RunTestCases(t *testing.T, testCases []TestCase)

RunTestCases executes a list of test cases for license validation

func ValidationResult added in v1.3.0

func ValidationResult(valid bool, daysLeft int) *model.ValidationResult

ValidationResult creates a validation result for testing

Types

type Fields

type Fields = map[string]any

Fields is a type alias for log.Fields

type MockLogger

type MockLogger struct {
	mock.Mock
}

MockLogger is a mock implementation of the log.Logger interface

func (*MockLogger) Debug

func (m *MockLogger) Debug(args ...any)

Debug implements log.Logger interface

func (*MockLogger) Debugf

func (m *MockLogger) Debugf(format string, args ...any)

Debugf implements log.Logger interface

func (*MockLogger) Error

func (m *MockLogger) Error(args ...any)

Error implements log.Logger interface

func (*MockLogger) Errorf

func (m *MockLogger) Errorf(format string, args ...any)

Errorf implements log.Logger interface

func (*MockLogger) Fatal

func (m *MockLogger) Fatal(args ...any)

Fatal implements log.Logger interface

func (*MockLogger) Fatalf

func (m *MockLogger) Fatalf(format string, args ...any)

Fatalf implements log.Logger interface

func (*MockLogger) Info

func (m *MockLogger) Info(args ...any)

Info implements log.Logger interface

func (*MockLogger) Infof

func (m *MockLogger) Infof(format string, args ...any)

Infof implements log.Logger interface

func (*MockLogger) Warn

func (m *MockLogger) Warn(args ...any)

Warn implements log.Logger interface

func (*MockLogger) Warnf

func (m *MockLogger) Warnf(format string, args ...any)

Warnf implements log.Logger interface

func (*MockLogger) WithContext

func (m *MockLogger) WithContext(ctx context.Context) *log.Logger

WithContext implements log.Logger interface

func (*MockLogger) WithError

func (m *MockLogger) WithError(err error) *log.Logger

WithError implements log.Logger interface

func (*MockLogger) WithField

func (m *MockLogger) WithField(key string, value any) *log.Logger

WithField implements log.Logger interface

func (*MockLogger) WithFields

func (m *MockLogger) WithFields(fields Fields) *log.Logger

WithFields implements log.Logger interface

type TestCase

type TestCase struct {
	Name              string
	SetupServer       func(*testing.T) *httptest.Server
	ExpectedValid     bool
	ExpectedGrace     bool
	ExpectedPanic     bool
	ExpectedDays      int
	ExpectedWarnLogs  int
	ExpectedErrorLogs int
}

TestCase defines the structure for a license validation test case

Jump to

Keyboard shortcuts

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