Skip to content

Commit

Permalink
Handle invalid deps.json file in NuGetPackageExplorerToCsvDriver
Browse files Browse the repository at this point in the history
  • Loading branch information
joelverhagen committed Jun 6, 2022
1 parent 5d9054b commit 18d694c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ private async Task<(NuGetPackageExplorerRecord, IReadOnlyList<NuGetPackageExplor
});
}
}
catch (FileNotFoundException ex)
catch (Exception ex) when (ex is FileNotFoundException || ex is FormatException)
{
_logger.LogWarning(ex, "Could not get symbol validator files for {Id} {Version}.", leaf.PackageId, leaf.PackageVersion);
return MakeSingleItem(scanId, scanTimestamp, leaf, NuGetPackageExplorerResultType.InvalidMetadata);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -403,5 +403,29 @@ public async Task EmptyProjectUrlIsInvalidMetadata()
var file = Assert.Single(Assert.Single(output.Value.Sets2).Records);
Assert.Equal(NuGetPackageExplorerResultType.InvalidMetadata, file.ResultType);
}

/// <summary>
/// Tracked by https://github.com/NuGetPackageExplorer/NuGetPackageExplorer/issues/1505
/// </summary>
[Fact]
public async Task ToolsPropertyMissingFromDepsJsonFileIsInvalidMetadata()
{
await Target.InitializeAsync();
var leaf = new CatalogLeafScan
{
Url = "https://api.nuget.org/v3/catalog0/data/2022.06.04.19.46.05/jetbrains.resharper.globaltools.2022.2.0-eap03.json",
LeafType = CatalogLeafType.PackageDetails,
PackageId = "JetBrains.ReSharper.GlobalTools",
PackageVersion = "2022.2.0-eap03",
};

var output = await Target.ProcessLeafAsync(leaf);

Assert.Equal(DriverResultType.Success, output.Type);
var record = Assert.Single(Assert.Single(output.Value.Sets1).Records);
Assert.Equal(NuGetPackageExplorerResultType.InvalidMetadata, record.ResultType);
var file = Assert.Single(Assert.Single(output.Value.Sets2).Records);
Assert.Equal(NuGetPackageExplorerResultType.InvalidMetadata, file.ResultType);
}
}
}

0 comments on commit 18d694c

Please sign in to comment.