Skip to content

Refactor Config so that FakeConfig extends Config and is easier to test/augment #164646

@matanlurey

Description

@matanlurey

Right now there is a rather weird pattern where FakeConfig implements Config, and has to redeclare everything:

class FakeConfig implements Config {
  FakeConfig({
    this.githubClient,
    this.deviceLabServiceAccountValue,
    this.maxTaskRetriesValue,
    this.maxLuciTaskRetriesValue,
    this.maxFilesChangedForSkippingEnginePhaseValue,
    this.keyHelperValue,
    this.oauthClientIdValue,
    this.githubOAuthTokenValue,
    this.mergeConflictPullRequestMessageValue = 'default mergeConflictPullRequestMessageValue',
    this.missingTestsPullRequestMessageValue = 'default missingTestsPullRequestMessageValue',
    this.wrongBaseBranchPullRequestMessageValue,
    this.wrongHeadBranchPullRequestMessageValue,
    this.releaseBranchPullRequestMessageValue,
    this.webhookKeyValue,
    this.loggingServiceValue,
    this.tabledataResource,
    this.githubService,
    this.bigqueryService,
    this.firestoreService,
    this.githubGraphQLClient,
    this.rollerAccountsValue,
    this.flutterBuildValue,
    this.flutterBuildDescriptionValue,
    this.maxRecordsValue,
    this.flutterGoldPendingValue,
    this.flutterGoldSuccessValue,
    this.flutterGoldChangesValue,
    this.flutterGoldAlertConstantValue,
    this.flutterGoldInitialAlertValue,
    this.flutterGoldFollowUpAlertValue,
    this.flutterGoldDraftChangeValue,
    this.flutterGoldStalePRValue,
    this.postsubmitSupportedReposValue,
    this.supportedBranchesValue,
    this.supportedReposValue,
    this.batchSizeValue,
    this.backfillerTargetLimitValue,
    this.backfillerCommitLimitValue,
    this.issueAndPRLimitValue,
    this.githubRequestDelayValue,

This makes augmenting this class cumbersome, because adding a new value means every FakeConfig becomes invalid unless it also passes in a default value, or you change every test. Ideally FakeConfig extends Config, and allows providing (overriding) certain values from the otherwise defaults.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listc: tech-debtTechnical debt, code quality, testing, etc.infra: cocoonRelated to the dashboard or cocoon serverteam-infraOwned by Infrastructure teamtriaged-infraTriaged by Infrastructure team

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions