From f30d535f0725dcd793f10f8e54d108645d9fd6fc Mon Sep 17 00:00:00 2001 From: leovct Date: Fri, 29 Nov 2024 13:09:06 +0100 Subject: [PATCH] test: add `GetAbsoluteLocator` test --- .../git_package_content_provider_test.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/core/server/api_container/server/startosis_engine/startosis_packages/git_package_content_provider/git_package_content_provider_test.go b/core/server/api_container/server/startosis_engine/startosis_packages/git_package_content_provider/git_package_content_provider_test.go index 43e450d672..490ffb2f9d 100644 --- a/core/server/api_container/server/startosis_engine/startosis_packages/git_package_content_provider/git_package_content_provider_test.go +++ b/core/server/api_container/server/startosis_engine/startosis_packages/git_package_content_provider/git_package_content_provider_test.go @@ -600,6 +600,17 @@ func TestGetAbsoluteLocator_AbsoluteLocatorIsInRootPackageButSourceIsNotShouldNo require.Nil(t, err) } +func TestGetAbsoluteLocator_RepositoriesWithSamePrefixNameShouldNotBeBlocked(t *testing.T) { + provider := NewGitPackageContentProvider("", "", NewGitHubPackageAuthProvider(""), nil) + + packageId := "github.com/main-package" + locatorOfModuleInWhichThisBuiltInIsBeingCalled := "github.com/main-package-xyz/main.star" // same package prefix + maybeRelativeLocator := "github.com/main-package/file.star" + + _, err := provider.GetAbsoluteLocator(packageId, locatorOfModuleInWhichThisBuiltInIsBeingCalled, maybeRelativeLocator, noPackageReplaceOptions) + require.Nil(t, err) +} + func Test_isSamePackageLocalAbsoluteLocator_TestDetectionInSubpath(t *testing.T) { result := shouldBlockAbsoluteLocatorBecauseIsInTheSameSourceModuleLocatorPackage("github.com/author/package/bang/lib.star", "github.com/author/package/main.star", "github.com/author/package/") require.True(t, result)