mocks

package
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ApprovedUsersStoreMock added in v1.5.1

type ApprovedUsersStoreMock struct {
	// DeleteFunc mocks the Delete method.
	DeleteFunc func(id string) error

	// StoreFunc mocks the Store method.
	StoreFunc func(ids []string) error

	// TimestampFunc mocks the Timestamp method.
	TimestampFunc func(id string) (time.Time, error)
	// contains filtered or unexported fields
}

ApprovedUsersStoreMock is a mock implementation of webapi.ApprovedUsersStore.

func TestSomethingThatUsesApprovedUsersStore(t *testing.T) {

	// make and configure a mocked webapi.ApprovedUsersStore
	mockedApprovedUsersStore := &ApprovedUsersStoreMock{
		DeleteFunc: func(id string) error {
			panic("mock out the Delete method")
		},
		StoreFunc: func(ids []string) error {
			panic("mock out the Store method")
		},
		TimestampFunc: func(id string) (time.Time, error) {
			panic("mock out the Timestamp method")
		},
	}

	// use mockedApprovedUsersStore in code that requires webapi.ApprovedUsersStore
	// and then make assertions.

}

func (*ApprovedUsersStoreMock) Delete added in v1.5.1

func (mock *ApprovedUsersStoreMock) Delete(id string) error

Delete calls DeleteFunc.

func (*ApprovedUsersStoreMock) DeleteCalls added in v1.5.1

func (mock *ApprovedUsersStoreMock) DeleteCalls() []struct {
	ID string
}

DeleteCalls gets all the calls that were made to Delete. Check the length with:

len(mockedApprovedUsersStore.DeleteCalls())

func (*ApprovedUsersStoreMock) ResetCalls added in v1.5.1

func (mock *ApprovedUsersStoreMock) ResetCalls()

ResetCalls reset all the calls that were made to all mocked methods.

func (*ApprovedUsersStoreMock) ResetDeleteCalls added in v1.5.1

func (mock *ApprovedUsersStoreMock) ResetDeleteCalls()

ResetDeleteCalls reset all the calls that were made to Delete.

func (*ApprovedUsersStoreMock) ResetStoreCalls added in v1.5.1

func (mock *ApprovedUsersStoreMock) ResetStoreCalls()

ResetStoreCalls reset all the calls that were made to Store.

func (*ApprovedUsersStoreMock) ResetTimestampCalls added in v1.5.1

func (mock *ApprovedUsersStoreMock) ResetTimestampCalls()

ResetTimestampCalls reset all the calls that were made to Timestamp.

func (*ApprovedUsersStoreMock) Store added in v1.5.1

func (mock *ApprovedUsersStoreMock) Store(ids []string) error

Store calls StoreFunc.

func (*ApprovedUsersStoreMock) StoreCalls added in v1.5.1

func (mock *ApprovedUsersStoreMock) StoreCalls() []struct {
	Ids []string
}

StoreCalls gets all the calls that were made to Store. Check the length with:

len(mockedApprovedUsersStore.StoreCalls())

func (*ApprovedUsersStoreMock) Timestamp added in v1.5.1

func (mock *ApprovedUsersStoreMock) Timestamp(id string) (time.Time, error)

Timestamp calls TimestampFunc.

func (*ApprovedUsersStoreMock) TimestampCalls added in v1.5.1

func (mock *ApprovedUsersStoreMock) TimestampCalls() []struct {
	ID string
}

TimestampCalls gets all the calls that were made to Timestamp. Check the length with:

len(mockedApprovedUsersStore.TimestampCalls())

type DetectorMock

type DetectorMock struct {
	// AddApprovedUsersFunc mocks the AddApprovedUsers method.
	AddApprovedUsersFunc func(ids ...string)

	// ApprovedUsersFunc mocks the ApprovedUsers method.
	ApprovedUsersFunc func() []string

	// CheckFunc mocks the Check method.
	CheckFunc func(msg string, userID string) (bool, []lib.CheckResult)

	// RemoveApprovedUsersFunc mocks the RemoveApprovedUsers method.
	RemoveApprovedUsersFunc func(ids ...string)
	// contains filtered or unexported fields
}

DetectorMock is a mock implementation of webapi.Detector.

func TestSomethingThatUsesDetector(t *testing.T) {

	// make and configure a mocked webapi.Detector
	mockedDetector := &DetectorMock{
		AddApprovedUsersFunc: func(ids ...string)  {
			panic("mock out the AddApprovedUsers method")
		},
		ApprovedUsersFunc: func() []string {
			panic("mock out the ApprovedUsers method")
		},
		CheckFunc: func(msg string, userID string) (bool, []lib.CheckResult) {
			panic("mock out the Check method")
		},
		RemoveApprovedUsersFunc: func(ids ...string)  {
			panic("mock out the RemoveApprovedUsers method")
		},
	}

	// use mockedDetector in code that requires webapi.Detector
	// and then make assertions.

}

func (*DetectorMock) AddApprovedUsers

func (mock *DetectorMock) AddApprovedUsers(ids ...string)

AddApprovedUsers calls AddApprovedUsersFunc.

func (*DetectorMock) AddApprovedUsersCalls

func (mock *DetectorMock) AddApprovedUsersCalls() []struct {
	Ids []string
}

AddApprovedUsersCalls gets all the calls that were made to AddApprovedUsers. Check the length with:

len(mockedDetector.AddApprovedUsersCalls())

func (*DetectorMock) ApprovedUsers

func (mock *DetectorMock) ApprovedUsers() []string

ApprovedUsers calls ApprovedUsersFunc.

func (*DetectorMock) ApprovedUsersCalls

func (mock *DetectorMock) ApprovedUsersCalls() []struct {
}

ApprovedUsersCalls gets all the calls that were made to ApprovedUsers. Check the length with:

len(mockedDetector.ApprovedUsersCalls())

func (*DetectorMock) Check

func (mock *DetectorMock) Check(msg string, userID string) (bool, []lib.CheckResult)

Check calls CheckFunc.

func (*DetectorMock) CheckCalls

func (mock *DetectorMock) CheckCalls() []struct {
	Msg    string
	UserID string
}

CheckCalls gets all the calls that were made to Check. Check the length with:

len(mockedDetector.CheckCalls())

func (*DetectorMock) RemoveApprovedUsers

func (mock *DetectorMock) RemoveApprovedUsers(ids ...string)

RemoveApprovedUsers calls RemoveApprovedUsersFunc.

func (*DetectorMock) RemoveApprovedUsersCalls

func (mock *DetectorMock) RemoveApprovedUsersCalls() []struct {
	Ids []string
}

RemoveApprovedUsersCalls gets all the calls that were made to RemoveApprovedUsers. Check the length with:

len(mockedDetector.RemoveApprovedUsersCalls())

func (*DetectorMock) ResetAddApprovedUsersCalls

func (mock *DetectorMock) ResetAddApprovedUsersCalls()

ResetAddApprovedUsersCalls reset all the calls that were made to AddApprovedUsers.

func (*DetectorMock) ResetApprovedUsersCalls

func (mock *DetectorMock) ResetApprovedUsersCalls()

ResetApprovedUsersCalls reset all the calls that were made to ApprovedUsers.

func (*DetectorMock) ResetCalls

func (mock *DetectorMock) ResetCalls()

ResetCalls reset all the calls that were made to all mocked methods.

func (*DetectorMock) ResetCheckCalls

func (mock *DetectorMock) ResetCheckCalls()

ResetCheckCalls reset all the calls that were made to Check.

func (*DetectorMock) ResetRemoveApprovedUsersCalls

func (mock *DetectorMock) ResetRemoveApprovedUsersCalls()

ResetRemoveApprovedUsersCalls reset all the calls that were made to RemoveApprovedUsers.

type LocatorMock added in v1.5.0

type LocatorMock struct {
	// UserIDByNameFunc mocks the UserIDByName method.
	UserIDByNameFunc func(userName string) int64

	// UserNameByIDFunc mocks the UserNameByID method.
	UserNameByIDFunc func(userID int64) string
	// contains filtered or unexported fields
}

LocatorMock is a mock implementation of webapi.Locator.

func TestSomethingThatUsesLocator(t *testing.T) {

	// make and configure a mocked webapi.Locator
	mockedLocator := &LocatorMock{
		UserIDByNameFunc: func(userName string) int64 {
			panic("mock out the UserIDByName method")
		},
		UserNameByIDFunc: func(userID int64) string {
			panic("mock out the UserNameByID method")
		},
	}

	// use mockedLocator in code that requires webapi.Locator
	// and then make assertions.

}

func (*LocatorMock) ResetCalls added in v1.5.0

func (mock *LocatorMock) ResetCalls()

ResetCalls reset all the calls that were made to all mocked methods.

func (*LocatorMock) ResetUserIDByNameCalls added in v1.5.0

func (mock *LocatorMock) ResetUserIDByNameCalls()

ResetUserIDByNameCalls reset all the calls that were made to UserIDByName.

func (*LocatorMock) ResetUserNameByIDCalls added in v1.5.0

func (mock *LocatorMock) ResetUserNameByIDCalls()

ResetUserNameByIDCalls reset all the calls that were made to UserNameByID.

func (*LocatorMock) UserIDByName added in v1.5.0

func (mock *LocatorMock) UserIDByName(userName string) int64

UserIDByName calls UserIDByNameFunc.

func (*LocatorMock) UserIDByNameCalls added in v1.5.0

func (mock *LocatorMock) UserIDByNameCalls() []struct {
	UserName string
}

UserIDByNameCalls gets all the calls that were made to UserIDByName. Check the length with:

len(mockedLocator.UserIDByNameCalls())

func (*LocatorMock) UserNameByID added in v1.5.0

func (mock *LocatorMock) UserNameByID(userID int64) string

UserNameByID calls UserNameByIDFunc.

func (*LocatorMock) UserNameByIDCalls added in v1.5.0

func (mock *LocatorMock) UserNameByIDCalls() []struct {
	UserID int64
}

UserNameByIDCalls gets all the calls that were made to UserNameByID. Check the length with:

len(mockedLocator.UserNameByIDCalls())

type SpamFilterMock added in v1.5.0

type SpamFilterMock struct {
	// DynamicSamplesFunc mocks the DynamicSamples method.
	DynamicSamplesFunc func() ([]string, []string, error)

	// ReloadSamplesFunc mocks the ReloadSamples method.
	ReloadSamplesFunc func() error

	// RemoveDynamicHamSampleFunc mocks the RemoveDynamicHamSample method.
	RemoveDynamicHamSampleFunc func(sample string) (int, error)

	// RemoveDynamicSpamSampleFunc mocks the RemoveDynamicSpamSample method.
	RemoveDynamicSpamSampleFunc func(sample string) (int, error)

	// UpdateHamFunc mocks the UpdateHam method.
	UpdateHamFunc func(msg string) error

	// UpdateSpamFunc mocks the UpdateSpam method.
	UpdateSpamFunc func(msg string) error
	// contains filtered or unexported fields
}

SpamFilterMock is a mock implementation of webapi.SpamFilter.

func TestSomethingThatUsesSpamFilter(t *testing.T) {

	// make and configure a mocked webapi.SpamFilter
	mockedSpamFilter := &SpamFilterMock{
		DynamicSamplesFunc: func() ([]string, []string, error) {
			panic("mock out the DynamicSamples method")
		},
		ReloadSamplesFunc: func() error {
			panic("mock out the ReloadSamples method")
		},
		RemoveDynamicHamSampleFunc: func(sample string) (int, error) {
			panic("mock out the RemoveDynamicHamSample method")
		},
		RemoveDynamicSpamSampleFunc: func(sample string) (int, error) {
			panic("mock out the RemoveDynamicSpamSample method")
		},
		UpdateHamFunc: func(msg string) error {
			panic("mock out the UpdateHam method")
		},
		UpdateSpamFunc: func(msg string) error {
			panic("mock out the UpdateSpam method")
		},
	}

	// use mockedSpamFilter in code that requires webapi.SpamFilter
	// and then make assertions.

}

func (*SpamFilterMock) DynamicSamples added in v1.5.0

func (mock *SpamFilterMock) DynamicSamples() ([]string, []string, error)

DynamicSamples calls DynamicSamplesFunc.

func (*SpamFilterMock) DynamicSamplesCalls added in v1.5.0

func (mock *SpamFilterMock) DynamicSamplesCalls() []struct {
}

DynamicSamplesCalls gets all the calls that were made to DynamicSamples. Check the length with:

len(mockedSpamFilter.DynamicSamplesCalls())

func (*SpamFilterMock) ReloadSamples added in v1.5.0

func (mock *SpamFilterMock) ReloadSamples() error

ReloadSamples calls ReloadSamplesFunc.

func (*SpamFilterMock) ReloadSamplesCalls added in v1.5.0

func (mock *SpamFilterMock) ReloadSamplesCalls() []struct {
}

ReloadSamplesCalls gets all the calls that were made to ReloadSamples. Check the length with:

len(mockedSpamFilter.ReloadSamplesCalls())

func (*SpamFilterMock) RemoveDynamicHamSample added in v1.5.0

func (mock *SpamFilterMock) RemoveDynamicHamSample(sample string) (int, error)

RemoveDynamicHamSample calls RemoveDynamicHamSampleFunc.

func (*SpamFilterMock) RemoveDynamicHamSampleCalls added in v1.5.0

func (mock *SpamFilterMock) RemoveDynamicHamSampleCalls() []struct {
	Sample string
}

RemoveDynamicHamSampleCalls gets all the calls that were made to RemoveDynamicHamSample. Check the length with:

len(mockedSpamFilter.RemoveDynamicHamSampleCalls())

func (*SpamFilterMock) RemoveDynamicSpamSample added in v1.5.0

func (mock *SpamFilterMock) RemoveDynamicSpamSample(sample string) (int, error)

RemoveDynamicSpamSample calls RemoveDynamicSpamSampleFunc.

func (*SpamFilterMock) RemoveDynamicSpamSampleCalls added in v1.5.0

func (mock *SpamFilterMock) RemoveDynamicSpamSampleCalls() []struct {
	Sample string
}

RemoveDynamicSpamSampleCalls gets all the calls that were made to RemoveDynamicSpamSample. Check the length with:

len(mockedSpamFilter.RemoveDynamicSpamSampleCalls())

func (*SpamFilterMock) ResetCalls added in v1.5.0

func (mock *SpamFilterMock) ResetCalls()

ResetCalls reset all the calls that were made to all mocked methods.

func (*SpamFilterMock) ResetDynamicSamplesCalls added in v1.5.0

func (mock *SpamFilterMock) ResetDynamicSamplesCalls()

ResetDynamicSamplesCalls reset all the calls that were made to DynamicSamples.

func (*SpamFilterMock) ResetReloadSamplesCalls added in v1.5.0

func (mock *SpamFilterMock) ResetReloadSamplesCalls()

ResetReloadSamplesCalls reset all the calls that were made to ReloadSamples.

func (*SpamFilterMock) ResetRemoveDynamicHamSampleCalls added in v1.5.0

func (mock *SpamFilterMock) ResetRemoveDynamicHamSampleCalls()

ResetRemoveDynamicHamSampleCalls reset all the calls that were made to RemoveDynamicHamSample.

func (*SpamFilterMock) ResetRemoveDynamicSpamSampleCalls added in v1.5.0

func (mock *SpamFilterMock) ResetRemoveDynamicSpamSampleCalls()

ResetRemoveDynamicSpamSampleCalls reset all the calls that were made to RemoveDynamicSpamSample.

func (*SpamFilterMock) ResetUpdateHamCalls added in v1.5.0

func (mock *SpamFilterMock) ResetUpdateHamCalls()

ResetUpdateHamCalls reset all the calls that were made to UpdateHam.

func (*SpamFilterMock) ResetUpdateSpamCalls added in v1.5.0

func (mock *SpamFilterMock) ResetUpdateSpamCalls()

ResetUpdateSpamCalls reset all the calls that were made to UpdateSpam.

func (*SpamFilterMock) UpdateHam added in v1.5.0

func (mock *SpamFilterMock) UpdateHam(msg string) error

UpdateHam calls UpdateHamFunc.

func (*SpamFilterMock) UpdateHamCalls added in v1.5.0

func (mock *SpamFilterMock) UpdateHamCalls() []struct {
	Msg string
}

UpdateHamCalls gets all the calls that were made to UpdateHam. Check the length with:

len(mockedSpamFilter.UpdateHamCalls())

func (*SpamFilterMock) UpdateSpam added in v1.5.0

func (mock *SpamFilterMock) UpdateSpam(msg string) error

UpdateSpam calls UpdateSpamFunc.

func (*SpamFilterMock) UpdateSpamCalls added in v1.5.0

func (mock *SpamFilterMock) UpdateSpamCalls() []struct {
	Msg string
}

UpdateSpamCalls gets all the calls that were made to UpdateSpam. Check the length with:

len(mockedSpamFilter.UpdateSpamCalls())

Jump to

Keyboard shortcuts

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