mirror of
https://github.com/fleetdm/fleet
synced 2026-04-21 21:47:20 +00:00
<!-- 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 -->
1.5 KiB
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 |