Skip to content

feat: allow overriding desktop and distro for tests#501

Open
adil192 wants to merge 1 commit intocanonical:mainfrom
adil192:feat/override-distro
Open

feat: allow overriding desktop and distro for tests#501
adil192 wants to merge 1 commit intocanonical:mainfrom
adil192:feat/override-distro

Conversation

@adil192
Copy link

@adil192 adil192 commented Dec 9, 2025

In a test for my app, I wanted to have platform.isUbuntu be true. But there wasn't an easy way to set the distro without specifying the entire os-release file.

This PR adds PlatformLinuxDistro.osIdOverride and PlatformLinuxDesktop.xdgCurrentDesktopOverride so users of the platform_linux package can override the distro/desktop.

Before this PR:

IOOverrides.runZoned(
  () {
    final platform = FakePlatform(
      environment: {
        'XDG_CURRENT_DESKTOP': 'GNOME',
      },
    );
  },
  createFile: MockTextFiles({
    '/etc/os-release': MockTextFile('''
PRETTY_NAME="Ubuntu 23.04"
NAME="Ubuntu"
VERSION_ID="23.04"
VERSION="23.04 (Lunar Lobster)"
VERSION_CODENAME=lunar
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=lunar
LOGO=ubuntu-logo
'''),
  }).call,
);

After this PR:

final platform = FakePlatform();
platform.xdgDesktopOverride = ['gnome'];
platform.distroOverride = 'ubuntu';

@adil192 adil192 marked this pull request as draft December 9, 2025 17:57
@adil192 adil192 marked this pull request as ready for review December 9, 2025 18:08
@adil192

This comment was marked as outdated.

@adil192 adil192 force-pushed the feat/override-distro branch from d0aea55 to 10c33ce Compare February 19, 2026 00:56
@adil192 adil192 changed the title feat: allow overriding desktop and distro feat: allow overriding desktop and distro for tests Feb 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant