Skip to content

Commit

Permalink
[ANE-698] Add an integration test for NuGet fallback to project.asset…
Browse files Browse the repository at this point in the history
…s.json
  • Loading branch information
jcc333 committed Jan 9, 2025
1 parent b31aa93 commit 6ca758d
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions integration-test/Analysis/NugetSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,18 @@ module Analysis.NugetSpec (spec) where

import Analysis.FixtureExpectationUtils
import Analysis.FixtureUtils
import Data.Set qualified as Set
import Data.Set (member)
import Discovery.Walk (fileName)
import Path

import Strategy.NuGet qualified as NuGet
import Strategy.NuGet.PackagesConfig qualified as PackagesConfig
import Test.Hspec
import Types

import Debug.Trace (trace)

Check failure on line 18 in integration-test/Analysis/NugetSpec.hs

View workflow job for this annotation

GitHub Actions / Windows-build

The import of ‘Debug.Trace’ is redundant

Check failure on line 18 in integration-test/Analysis/NugetSpec.hs

View workflow job for this annotation

GitHub Actions / Windows-build

The import of ‘Debug.Trace’ is redundant

Check failure on line 18 in integration-test/Analysis/NugetSpec.hs

View workflow job for this annotation

GitHub Actions / macOS-arm64-build

The import of ‘Debug.Trace’ is redundant

Check failure on line 18 in integration-test/Analysis/NugetSpec.hs

View workflow job for this annotation

GitHub Actions / macOS-arm64-build

The import of ‘Debug.Trace’ is redundant

serviceStack :: (Path Abs Dir -> TestC IO [DiscoveredProject a]) -> AnalysisTestFixture a
serviceStack discoveryFunc =
AnalysisTestFixture
Expand All @@ -24,6 +29,19 @@ serviceStack discoveryFunc =
[reldir|nuget/ServiceStack/|]
[reldir|servicestack-5.13.2//|]

dotnetCoreTwoExample :: (Path Abs Dir -> TestC IO [DiscoveredProject a]) -> AnalysisTestFixture a
dotnetCoreTwoExample discoveryFunc =
AnalysisTestFixture
"ServiceStack"
discoveryFunc
LocalEnvironment
Nothing
$ FixtureArtifact
"https://github.com/james-fossa/dotnet-core-2.0-example/archive/refs/tags/0.0.1.tar.gz"
[reldir|nuget/dotnet-core-2.0-example-0.0.1/|]
[reldir|dotnet-core-2.0-example-0.0.1//|]


testServiceStackForPkgReferences :: Spec
testServiceStackForPkgReferences =
aroundAll (withAnalysisOf $ serviceStack NuGet.discover) $ do
Expand All @@ -38,7 +56,20 @@ testServiceStackForPkgConfig =
it "should find targets" $ \(result, _) -> do
length result `shouldBe` 4

testDotnetCoreTwoExampleForPackageAssetsJson :: Spec
testDotnetCoreTwoExampleForPackageAssetsJson =
aroundAll (withAnalysisOf $ dotnetCoreTwoExample NuGet.discover) $ do
describe "dotnet-core-2.0-example" $ do
it "should find targets" $ \(result, _) -> do
length result `shouldBe` 2
let projectDataPaths = Set.fromList $ map (fileName . NuGet.nugetProjectFile . Types.projectData . fst) result
let doesProjectAssetsJsonTargetExist = member "project.assets.json" projectDataPaths
let doesCsprojTargetExist = member "example.csproj" projectDataPaths
doesProjectAssetsJsonTargetExist `shouldBe` True
doesCsprojTargetExist `shouldBe` True

spec :: Spec
spec = do
testServiceStackForPkgReferences
testServiceStackForPkgConfig
testDotnetCoreTwoExampleForPackageAssetsJson

0 comments on commit 6ca758d

Please sign in to comment.