Documentation
¶
Overview ¶
Package testsupport provides a text fixture that sets up unit tests for the fleet cost server.
Package testsupport provides the `NewFixture` function, which produces a context and a frontend that's suitable for testing.
Index ¶
- func NewMatcher(message string, predicate func(any) bool) gomock.Matcher
- type Fixture
- func (tf *Fixture) AdvanceClock(d time.Duration)
- func (tf *Fixture) Clock() testclock.TestClock
- func (tf *Fixture) RegisterDUTsForLabstation(reqMatcher gomock.Matcher, resp *ufsAPI.GetDUTsForLabstationResponse)
- func (tf *Fixture) RegisterGetChromeOSDeviceDataCall(reqMatcher gomock.Matcher, resp *ufspb.ChromeOSDeviceData)
- func (tf *Fixture) RegisterGetDeviceDataCall(reqMatcher gomock.Matcher, resp *ufsAPI.GetDeviceDataResponse)
- func (tf *Fixture) RegisterGetDeviceDataFailure(reqMatcher gomock.Matcher, failure error)
- func (tf *Fixture) RegisterListMachineLSEs(reqMatcher gomock.Matcher, resp *ufsAPI.ListMachineLSEsResponse)
- type SimpleMatcher
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Fixture ¶
type Fixture struct { Ctx context.Context Frontend *costserver.FleetCostFrontend MockUFS *mockufs.MockFleetClient }
Fixture creates a new test fixture for the fleet cost service and the backend services it talks to.
For each of the backend services, we use the best test implementation available. Datastore uses the LUCI in-memory representation, so it doesn't get an explicit field. UFS uses the go-mock generated stub.
func NewFixture ¶
NewFixture creates a basic fixture with fake versions of datastore and UFS with properties that are convenient for unit tests.
func NewFixtureWithData ¶
NewFixtureWithData returns a fixture with test data.
func (*Fixture) AdvanceClock ¶
AdvanceClock advances the clock by a duration.
func (*Fixture) RegisterDUTsForLabstation ¶
func (tf *Fixture) RegisterDUTsForLabstation(reqMatcher gomock.Matcher, resp *ufsAPI.GetDUTsForLabstationResponse)
RegisterDUTsForLabstation registers a GetChromeOSDeviceData request and response.
func (*Fixture) RegisterGetChromeOSDeviceDataCall ¶
func (tf *Fixture) RegisterGetChromeOSDeviceDataCall(reqMatcher gomock.Matcher, resp *ufspb.ChromeOSDeviceData)
RegisterGetChromeOSDeviceDataCall registers a GetChromeOSDeviceData request and response.
func (*Fixture) RegisterGetDeviceDataCall ¶
func (tf *Fixture) RegisterGetDeviceDataCall(reqMatcher gomock.Matcher, resp *ufsAPI.GetDeviceDataResponse)
RegisterGetDeviceDataCall registers a GetDeviceData request and response.
func (*Fixture) RegisterGetDeviceDataFailure ¶
RegisterGetDeviceDataFailure registers a failing GetDeviceData response.
No attempt is made to ensure that the error that we get back is realistic. TODO(gregorynisbet): Check the error for reasonableness and make sure it resembles a UFS error and panic if it does not resemble one.
func (*Fixture) RegisterListMachineLSEs ¶
func (tf *Fixture) RegisterListMachineLSEs(reqMatcher gomock.Matcher, resp *ufsAPI.ListMachineLSEsResponse)
RegisterListMachineLSEs registers a listMachineLSEs request.
type SimpleMatcher ¶
SimpleMatcher takes an artbirary function and makes it a matcher.
func (SimpleMatcher) Matches ¶
func (matcher SimpleMatcher) Matches(item any) bool
Matches determines whether an item fulfills the predicate.
func (SimpleMatcher) String ¶
func (matcher SimpleMatcher) String() string
String returns the matcher message.