fleet/server/archtest/README.md
Victor Lyuboslavsky cfc944e49a
Updated archtest to be more ergonomic (#37433)
<!-- Add the related story/sub-task/bug number, like Resolves #123, or
remove if NA -->
**Related issue:** Resolves #37241

Test changes only. Updated `archtest` to be more ergonomic. See README


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **New Features**
* Enhanced archtest package with new API methods for more granular
dependency filtering: `IgnoreRecursively()`, `IgnoreDeps()`,
`WithTests()`, and `WithTestsRecursively()`.
  * Added `Check()` method to finalize dependency verification.

* **Documentation**
* Added comprehensive README for archtest package with usage examples
and fluent API method reference.

<sub>✏️ Tip: You can customize this high-level summary in your review
settings.</sub>

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-12-18 09:28:41 -06:00

1.5 KiB

archtest

Architecture testing package for enforcing package dependency rules.

Usage

func TestMyPackageDependencies(t *testing.T) {
    archtest.NewPackageTest(t, "github.com/example/mypackage/...").
        OnlyInclude(regexp.MustCompile(`^github\.com/example/`)).
        WithTests().
        ShouldNotDependOn("github.com/example/forbidden/...").
        IgnoreDeps("github.com/example/infra/...").
        Check()
}

Methods

Method Description
OnlyInclude(regex) Filter to only check packages matching the regex (for performance)
ShouldNotDependOn(pkgs...) Specify forbidden dependencies
IgnoreRecursively(pkgs...) Skip packages entirely (including their transitive deps); try not to use
IgnoreDeps(pkgs...) Allow packages but still check their transitive deps
WithTests() Include test imports from root packages only
WithTestsRecursively() Include test imports from all packages
IgnoreXTests(pkgs...) Ignore external test packages (_test suffix)
Check() Run the dependency check