-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adding smoke tests for multiple .net versions (#209)
- Loading branch information
Showing
3 changed files
with
128 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { describe, expect, it } from '@jest/globals'; | ||
import * as fs from 'fs'; | ||
import * as path from 'path'; | ||
import * as plugin from '../../lib'; | ||
import * as dotnet from '../../lib/nuget-parser/cli/dotnet'; | ||
import { legacyPlugin as pluginApi } from '@snyk/cli-interface'; | ||
|
||
describe('generating v2 depgraphs using all supported .NET SDKs', () => { | ||
it.each([ | ||
{ | ||
description: 'parse dotnet 6.0', | ||
projectPath: './test/fixtures/dotnetcore/dotnet_6', | ||
}, | ||
])( | ||
'succeeds given a project file and returns a single dependency graph for single-targetFramework projects: $description', | ||
async ({ projectPath }) => { | ||
// Run a dotnet restore beforehand, in order to be able to supply a project.assets.json file | ||
const manifestFilePath = await dotnet.restore(projectPath); | ||
|
||
const result = await plugin.inspect(projectPath, manifestFilePath, { | ||
'dotnet-runtime-resolution': true, | ||
}); | ||
|
||
if (!pluginApi.isMultiResult(result)) { | ||
throw new Error('expected a multiResult response from inspection'); | ||
} | ||
|
||
expect(result.scannedProjects.length).toEqual(1); | ||
|
||
const expectedGraph = JSON.parse( | ||
fs.readFileSync( | ||
path.resolve(projectPath, 'expected_depgraph.json'), | ||
'utf-8', | ||
), | ||
); | ||
expect(result.scannedProjects[0].depGraph?.toJSON()).toEqual( | ||
expectedGraph.depGraph, | ||
); | ||
}, | ||
); | ||
}); |