contract

package
v2.3.0-beta28 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package contract provides the implementation of the contract service

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendInParameters

func AppendInParameters(parameters []models.Parameter, inParameters map[string]string, paramType string) []models.Parameter

func ExtractIdentifiers

func ExtractIdentifiers(path string) []string

ExtractIdentifiers extracts numeric identifiers (integers or floats) from the path.

func ExtractQueryParams

func ExtractQueryParams(rawURL string) (map[string]string, error)

ExtractQueryParams extracts the query parameters and their names from the URL.

func ExtractURLPath

func ExtractURLPath(URL string) (string, string)

func ExtractVariableTypes

func ExtractVariableTypes(obj map[string]interface{}) map[string]map[string]interface{}

ExtractVariableTypes returns the type of each variable in the object.

func GenerateDummyNamesForIdentifiers

func GenerateDummyNamesForIdentifiers(identifiers []string) map[string]string

GenerateDummyNamesForIdentifiers generates dummy names for the path identifiers.

func GenerateHeader

func GenerateHeader(header map[string]string) []models.Parameter

func GenerateResponse

func GenerateResponse(response Response) map[string]models.ResponseItem

func ReplacePathIdentifiers

func ReplacePathIdentifiers(path string, dummyNames map[string]string) string

ReplacePathIdentifiers replaces numeric identifiers in the path with their corresponding dummy names.

Types

type MockDB

type MockDB interface {
	GetHTTPMocks(ctx context.Context, testSetID string, mockPath string, mockFileName string) ([]*models.HTTPDoc, error)
}

type OpenAPIDB

type OpenAPIDB interface {
	GetTestCasesSchema(ctx context.Context, testSetID string, testPath string) ([]*models.OpenAPI, error)
	GetMocksSchemas(ctx context.Context, testSetID string, mockPath string, mockFileName string) ([]*models.OpenAPI, error)
	WriteSchema(ctx context.Context, logger *zap.Logger, outputPath, name string, openapi models.OpenAPI, isAppend bool) error
	ChangePath(path string)
}

type Response

type Response struct {
	Code    int
	Message string
	Types   map[string]map[string]interface{}
	Body    map[string]interface{}
}

type Service

type Service interface {
	Generate(ctx context.Context, checkConfig bool) error
	Download(ctx context.Context, checkConfig bool) error
	Validate(ctx context.Context) error
}

Service defines the contract service interface

func New

func New(logger *zap.Logger, testDB TestDB, mockDB MockDB, openAPIDB OpenAPIDB, config *config.Config) Service

type TestDB

type TestDB interface {
	GetAllTestSetIDs(ctx context.Context) ([]string, error)
	GetTestCases(ctx context.Context, testSetID string) ([]*models.TestCase, error)
	ChangePath(path string)
}

Directories

Path Synopsis
Package consumer is a package for consumer driven contract testing
Package consumer is a package for consumer driven contract testing
Package provider is a package for provider driven contract testing
Package provider is a package for provider driven contract testing

Jump to

Keyboard shortcuts

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