mocks

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TestCases = []testCaseStruct{
	{
		Config: config.Config{
			Host: "localhost",
			Port: "8000",
			Backends: []config.Backend{
				{
					Url:    "localhost:8080",
					Weight: 1,
				},
				{
					Url:    "localhost:80",
					Weight: 1,
				},
			},
			HealthCheckerTime: time.Second * 5,
			HealthCheckerFunc: func(string) bool {
				return true
			},
			HashFunc: func(b []byte) uint32 {
				return uint32(len(b))
			},
		},
		ExpectedServerCount: 2,
		ProxyFunc:           CreateNewMockProxy,
	},
	{
		Config: config.Config{
			Host: "localhost",
			Port: "8000",
			Backends: []config.Backend{
				{
					Url:    "localhost:8080",
					Weight: 1,
				},
			},
			HealthCheckerTime: time.Second * 5,
			HealthCheckerFunc: func(string) bool {
				return true
			},
			HashFunc: func(b []byte) uint32 {
				return uint32(len(b))
			},
		},
		ExpectedServerCount: 1,
		ProxyFunc:           CreateNewMockProxy,
	},
	{
		Config: config.Config{
			Host: "localhost",
			Port: "8000",
			Backends: []config.Backend{
				{
					Url:    "localhost:8080",
					Weight: 1,
				},
				{
					Url:    "localhost:80",
					Weight: 1,
				},
			},
			HealthCheckerTime: time.Second * 5,
			HealthCheckerFunc: func(string) bool {
				return false
			},
			HashFunc: func(b []byte) uint32 {
				return uint32(len(b))
			},
		},
		ExpectedServerCount: 0,
		ProxyFunc:           CreateNewMockProxy,
	},
	{
		Config: config.Config{
			Host:              "localhost",
			Port:              "8000",
			Backends:          []config.Backend{},
			HealthCheckerTime: time.Second * 5,
			HealthCheckerFunc: func(s string) bool {
				return false

			},
			HashFunc: func(b []byte) uint32 {
				return uint32(len(b))
			},
		},
		ExpectedServerCount: 0,
		ProxyFunc:           CreateNewMockProxy,
	},
	{
		Config: config.Config{
			Host: "localhost",
			Port: "8000",
			Backends: []config.Backend{
				{
					Url:    "localhost:7070",
					Weight: 1,
				},
				{
					Url:    "localhost:80",
					Weight: 1,
				},
			},
			HealthCheckerTime: time.Second * 5,
			HealthCheckerFunc: func(string) bool {
				return true
			},
			HashFunc: func(b []byte) uint32 {
				return uint32(len(b))
			},
		},
		ExpectedServerCount: 2,
		ProxyFunc:           CreateNewMockProxy,
	},
}

Functions

func CreateNewMockProxy

func CreateNewMockProxy(b config.Backend, h map[string]string) proxy.IProxyClient

Types

type MockProxy

type MockProxy struct {
	Addr     string
	IsCalled bool
	// contains filtered or unexported fields
}

func (*MockProxy) PendingRequests added in v0.2.0

func (m *MockProxy) PendingRequests() int

func (*MockProxy) ReverseProxyHandler

func (m *MockProxy) ReverseProxyHandler(ctx *fasthttp.RequestCtx) error

func (*MockProxy) Stat

func (m *MockProxy) Stat() types.ProxyStat

Jump to

Keyboard shortcuts

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