Skip to content

bug: provider discovery tests fail when system providers are installed #881

Description

@marcusburghardt

Description

DiscoverProviders() in pkg/provider/discovery.go:35-59 unconditionally scans the hard-coded system directory (/usr/libexec/complytime/providers, defined as SystemProviderDir in internal/complytime/consts.go:72) after scanning the user-provided directory. There is no mechanism to disable or override the system directory path.

Tests that assume an empty or controlled provider set fail on machines with system-installed providers (e.g., from RPM packages).

Affected Tests

4 tests in pkg/provider/:

Test File:Line Expected Actual
TestDiscoverProviders_EmptyDir discovery_test.go:23 empty 3 system providers
TestDiscoverProviders_NonPrefixedExecutables discovery_test.go:33 empty 3 system providers
TestDiscoverProviders_ValidProvider discovery_test.go:43 1 mock provider 1 mock + 3 system
TestManager_EmptyProviderDir manager_test.go:75 empty 2 loaded providers

Reproduction

Install provider RPMs (or manually place executables at /usr/libexec/complytime/providers/), then run:

go test -race -v -run "TestDiscoverProviders_EmptyDir|TestDiscoverProviders_NonPrefixedExecutables|TestDiscoverProviders_ValidProvider|TestManager_EmptyProviderDir" ./pkg/provider/...

All four tests fail. CI does not reproduce this because CI runners have no system-installed providers.

Possible Fix

Add a mechanism to override or disable the system provider directory during tests, so discovery can be fully isolated from the host environment. The codebase already uses env var overrides for similar paths (XDG_CACHE_HOME, XDG_DATA_HOME, COMPLYTIME_WORKSPACE), which could serve as a pattern.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    Priority

    Low

    Effort

    Low

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions