Skip to content
This repository has been archived by the owner on Apr 1, 2022. It is now read-only.

fix(maven): Locators should include group ID #332

Merged
merged 2 commits into from
Aug 16, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/Strategy/Maven/DepTree.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module Strategy.Maven.DepTree (
-- * Exported for testing
DotGraph (..),
PackageId (..),
toDependency,
) where

import Control.Algebra (Has, run)
Expand Down Expand Up @@ -144,10 +145,10 @@ buildGraph :: [DotGraph] -> Graphing Dependency
buildGraph = gmap toDependency . foldMap toGraph

toDependency :: PackageId -> Dependency
toDependency PackageId{artifactName, artifactVersion, buildTag} =
toDependency PackageId{groupName, artifactName, artifactVersion, buildTag} =
Dependency
{ dependencyType = MavenType
, dependencyName = artifactName
, dependencyName = groupName <> ":" <> artifactName
, dependencyVersion = Just $ CEq artifactVersion
, dependencyLocations = []
, dependencyEnvironments = maybe [EnvProduction] ((: []) . toBuildTag) buildTag
Expand Down
36 changes: 34 additions & 2 deletions test/Maven/DepTreeSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,19 @@ module Maven.DepTreeSpec (spec) where

import Data.Text (Text)
import Data.Text.IO qualified as TextIO
import Strategy.Maven.DepTree (DotGraph (..), PackageId (..), parseDotGraphs)
import Test.Hspec (Spec, describe, it, runIO)
import DepTypes (
DepEnvironment (..),
DepType (MavenType),
Dependency (..),
VerConstraint (..),
)
import Strategy.Maven.DepTree (
DotGraph (..),
PackageId (..),
parseDotGraphs,
toDependency,
)
import Test.Hspec (Spec, describe, it, runIO, shouldBe)
import Test.Hspec.Megaparsec (shouldParse, shouldSucceedOn)
import Text.Megaparsec (parse)

Expand All @@ -30,6 +41,27 @@ spec =
parse parseDotGraphs "" fixturePackageIDWithPlatformContents
`shouldParse` fixturePackageIDWithPlatformGraph

it "renders parsed dependencies" $ do
let p =
PackageId
{ groupName = "org.apache.commons"
, artifactName = "commons-rng-parent"
, artifactType = "pom"
, artifactVersion = "1.4-SNAPSHOT"
, artifactPlatform = Nothing
, buildTag = Nothing
}
let d =
Dependency
{ dependencyType = MavenType
, dependencyName = "org.apache.commons:commons-rng-parent"
, dependencyVersion = Just (CEq "1.4-SNAPSHOT")
, dependencyLocations = []
, dependencyEnvironments = [EnvProduction]
, dependencyTags = mempty
}
toDependency p `shouldBe` d

fixtureSingleFile :: FilePath
fixtureSingleFile = "test/Maven/testdata/fossa-deptree.dot"

Expand Down