Skip to content

Commit

Permalink
test: with and without root package id trailing slash
Browse files Browse the repository at this point in the history
  • Loading branch information
leovct committed Nov 29, 2024
1 parent f3a167a commit eed3599
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -612,18 +612,33 @@ func TestGetAbsoluteLocator_RepositoriesWithSamePrefixNameShouldNotBeBlocked(t *
}

func Test_isSamePackageLocalAbsoluteLocator_TestDetectionInSubpath(t *testing.T) {
// Without root package id trailing slash.
result := shouldBlockAbsoluteLocatorBecauseIsInTheSameSourceModuleLocatorPackage("github.com/author/package/bang/lib.star", "github.com/author/package/main.star", "github.com/author/package")
require.True(t, result)

// With root package id trailing slash.
result = shouldBlockAbsoluteLocatorBecauseIsInTheSameSourceModuleLocatorPackage("github.com/author/package/bang/lib.star", "github.com/author/package/main.star", "github.com/author/package/")
require.True(t, result)
}

func Test_isSamePackageLocalAbsoluteLocator_TestDetectionInDifferentSubdirectories(t *testing.T) {
// Without root package id trailing slash.
result := shouldBlockAbsoluteLocatorBecauseIsInTheSameSourceModuleLocatorPackage("github.com/author/package/subdir1/file1.star", "github.com/author/package/subdir2/file2.star", "github.com/author/package")
require.True(t, result)

// With root package id trailing slash.
result = shouldBlockAbsoluteLocatorBecauseIsInTheSameSourceModuleLocatorPackage("github.com/author/package/subdir1/file1.star", "github.com/author/package/subdir2/file2.star", "github.com/author/package/")
require.True(t, result)
}

func Test_isNotSamePackageLocalAbsoluteLocator_TestRepositoriesWithSamePrefixNames(t *testing.T) {
// Without root package id trailing slash.
result := shouldBlockAbsoluteLocatorBecauseIsInTheSameSourceModuleLocatorPackage("github.com/author/package2/main.star", "github.com/author/package/main.star", "github.com/author/package")
require.False(t, result)

// With root package id trailing slash.
result = shouldBlockAbsoluteLocatorBecauseIsInTheSameSourceModuleLocatorPackage("github.com/author/package2/main.star", "github.com/author/package/main.star", "github.com/author/package/")
require.False(t, result)
}

func Test_getPathToPackageRoot(t *testing.T) {
Expand Down

0 comments on commit eed3599

Please sign in to comment.