mocks

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DetectedSpamMock added in v1.10.0

type DetectedSpamMock struct {
	// ReadFunc mocks the Read method.
	ReadFunc func() ([]storage.DetectedSpamInfo, error)

	// SetAddedToSamplesFlagFunc mocks the SetAddedToSamplesFlag method.
	SetAddedToSamplesFlagFunc func(id int64) error
	// contains filtered or unexported fields
}

DetectedSpamMock is a mock implementation of webapi.DetectedSpam.

func TestSomethingThatUsesDetectedSpam(t *testing.T) {

	// make and configure a mocked webapi.DetectedSpam
	mockedDetectedSpam := &DetectedSpamMock{
		ReadFunc: func() ([]storage.DetectedSpamInfo, error) {
			panic("mock out the Read method")
		},
		SetAddedToSamplesFlagFunc: func(id int64) error {
			panic("mock out the SetAddedToSamplesFlag method")
		},
	}

	// use mockedDetectedSpam in code that requires webapi.DetectedSpam
	// and then make assertions.

}

func (*DetectedSpamMock) Read added in v1.10.0

func (mock *DetectedSpamMock) Read() ([]storage.DetectedSpamInfo, error)

Read calls ReadFunc.

func (*DetectedSpamMock) ReadCalls added in v1.10.0

func (mock *DetectedSpamMock) ReadCalls() []struct {
}

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

len(mockedDetectedSpam.ReadCalls())

func (*DetectedSpamMock) ResetCalls added in v1.10.0

func (mock *DetectedSpamMock) ResetCalls()

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

func (*DetectedSpamMock) ResetReadCalls added in v1.10.0

func (mock *DetectedSpamMock) ResetReadCalls()

ResetReadCalls reset all the calls that were made to Read.

func (*DetectedSpamMock) ResetSetAddedToSamplesFlagCalls added in v1.10.0

func (mock *DetectedSpamMock) ResetSetAddedToSamplesFlagCalls()

ResetSetAddedToSamplesFlagCalls reset all the calls that were made to SetAddedToSamplesFlag.

func (*DetectedSpamMock) SetAddedToSamplesFlag added in v1.10.0

func (mock *DetectedSpamMock) SetAddedToSamplesFlag(id int64) error

SetAddedToSamplesFlag calls SetAddedToSamplesFlagFunc.

func (*DetectedSpamMock) SetAddedToSamplesFlagCalls added in v1.10.0

func (mock *DetectedSpamMock) SetAddedToSamplesFlagCalls() []struct {
	ID int64
}

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

len(mockedDetectedSpam.SetAddedToSamplesFlagCalls())

type DetectorMock

type DetectorMock struct {
	// AddApprovedUserFunc mocks the AddApprovedUser method.
	AddApprovedUserFunc func(user approved.UserInfo) error

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

	// CheckFunc mocks the Check method.
	CheckFunc func(req spamcheck.Request) (bool, []spamcheck.Response)

	// RemoveApprovedUserFunc mocks the RemoveApprovedUser method.
	RemoveApprovedUserFunc func(id string) error
	// 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{
		AddApprovedUserFunc: func(user approved.UserInfo) error {
			panic("mock out the AddApprovedUser method")
		},
		ApprovedUsersFunc: func() []approved.UserInfo {
			panic("mock out the ApprovedUsers method")
		},
		CheckFunc: func(req spamcheck.Request) (bool, []spamcheck.Response) {
			panic("mock out the Check method")
		},
		RemoveApprovedUserFunc: func(id string) error {
			panic("mock out the RemoveApprovedUser method")
		},
	}

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

}

func (*DetectorMock) AddApprovedUser added in v1.6.0

func (mock *DetectorMock) AddApprovedUser(user approved.UserInfo) error

AddApprovedUser calls AddApprovedUserFunc.

func (*DetectorMock) AddApprovedUserCalls added in v1.6.0

func (mock *DetectorMock) AddApprovedUserCalls() []struct {
	User approved.UserInfo
}

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

len(mockedDetector.AddApprovedUserCalls())

func (*DetectorMock) ApprovedUsers

func (mock *DetectorMock) ApprovedUsers() []approved.UserInfo

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(req spamcheck.Request) (bool, []spamcheck.Response)

Check calls CheckFunc.

func (*DetectorMock) CheckCalls

func (mock *DetectorMock) CheckCalls() []struct {
	Req spamcheck.Request
}

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

len(mockedDetector.CheckCalls())

func (*DetectorMock) RemoveApprovedUser added in v1.6.0

func (mock *DetectorMock) RemoveApprovedUser(id string) error

RemoveApprovedUser calls RemoveApprovedUserFunc.

func (*DetectorMock) RemoveApprovedUserCalls added in v1.6.0

func (mock *DetectorMock) RemoveApprovedUserCalls() []struct {
	ID string
}

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

len(mockedDetector.RemoveApprovedUserCalls())

func (*DetectorMock) ResetAddApprovedUserCalls added in v1.6.0

func (mock *DetectorMock) ResetAddApprovedUserCalls()

ResetAddApprovedUserCalls reset all the calls that were made to AddApprovedUser.

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) ResetRemoveApprovedUserCalls added in v1.6.0

func (mock *DetectorMock) ResetRemoveApprovedUserCalls()

ResetRemoveApprovedUserCalls reset all the calls that were made to RemoveApprovedUser.

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