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 ecfcc6a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs/features/manual-dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ Note: When parsed, YAML considers text that could be a decimal number (such as 1
Supported dependency types:

- `bower` - Bower dependencies that are typically found at [bower.io](https://registry.bower.io).
- <!-- markdown-link-check-disable-next-line -->
<!-- markdown-link-check-disable-next-line -->
- `cargo` - Rust dependencies that are typically found at [crates.io](https://crates.io/).
- `carthage` - Dependencies as specified by the [Carthage](https://github.com/Carthage/Carthage) package manager.
- `composer` - Dependencies specified by the PHP package manager [Composer](https://getcomposer.org/), which are located on [Packagist](https://packagist.org/).
- `cpan` - Dependencies located on the [CPAN package manager](https://www.cpan.org/).
- <!-- markdown-link-check-disable-next-line -->
<!-- markdown-link-check-disable-next-line -->
- `cran` - Dependencies located on the [CRAN](https://cran.r-project.org/) like repository.
- `gem` - Dependencies which can be found at [RubyGems.org](https://rubygems.org/).
- `git` - Github projects (which appear as dependencies in many package managers). Specified as the full GitHub repository `https://github.com/fossas/fossa-cli`.
Expand Down
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 ecfcc6a

Please sign in to comment.