Documentation ¶
Overview ¶
Package cfgtest allows to mock Swarming configs for tests.
Index ¶
Constants ¶
View Source
const ( // MockedSwarmingServer is URL of the Swarming server used in tests. MockedSwarmingServer = "https://mocked.swarming.example.com" // MockedCIPDServer is the CIPD server URL used in tests. MockedCIPDServer = "https://mocked.cipd.example.com" // MockedBotPackage is bot CIPD package used in tests. MockedBotPackage = "mocked/bot/package" // MockedAdminGroup is the admin group in the default mocked config. MockedAdminGroup = "tests-admin-group" )
Variables ¶
This section is empty.
Functions ¶
func MockConfigs ¶
func MockConfigs(ctx context.Context, configs *MockedConfigs) *cfg.Provider
MockConfigs puts configs into the datastore and loads them into a Provider.
Configs must be valid, panics if they are not.
Types ¶
type MockedCIPD ¶
type MockedCIPD struct {
// contains filtered or unexported fields
}
MockedCIPD mocks state in CIPD.
Implements cfg.CIPD.
func (*MockedCIPD) FetchInstance ¶
func (c *MockedCIPD) FetchInstance(ctx context.Context, server, cipdpkg, iid string) (pkg.Instance, error)
FetchInstance fetches contents of a package given via its instance ID.
func (*MockedCIPD) MockPackage ¶
func (c *MockedCIPD) MockPackage(cipdpkg, version string, files map[string]string)
MockPackage puts a mocked package into the CIPD storage.
func (*MockedCIPD) ResolveVersion ¶
func (c *MockedCIPD) ResolveVersion(ctx context.Context, server, cipdpkg, version string) (string, error)
ResolveVersion resolves a version label into a CIPD instance ID.
type MockedConfigs ¶
type MockedConfigs struct { Settings *configpb.SettingsCfg Pools *configpb.PoolsCfg Bots *configpb.BotsCfg Scripts map[string]string CIPD MockedCIPD }
MockedConfigs is a bundle of configs to use in tests.
func NewMockedConfigs ¶
func NewMockedConfigs() *MockedConfigs
NewMockedConfigs returns a default empty MockedConfigs.
func (*MockedConfigs) MockBot ¶
func (cfg *MockedConfigs) MockBot(botID, pool string) *configpb.BotGroup
MockBot adds a bot in some pool.
func (*MockedConfigs) MockBotPackage ¶
func (cfg *MockedConfigs) MockBotPackage(cipdVersion string, files map[string]string)
MockBotPackage mocks existence of a bot package in the CIPD and configs.
Click to show internal directories.
Click to hide internal directories.