From e6c723d67a12871c354d720bf536b13b0b7f6588 Mon Sep 17 00:00:00 2001 From: realmarv Date: Thu, 6 Jul 2023 12:39:50 +0330 Subject: [PATCH] FileConventions.Test: add failing test Add failing test for detecting unpinned version in npm package installations. --- ...mmyCIWithUnpinnedNpmPackageInstallVersion.yml | 11 +++++++++++ src/FileConventions.Test/FileConventions.Test.fs | 16 ++++++++++++++++ src/FileConventions/Library.fs | 3 +++ 3 files changed, 30 insertions(+) create mode 100644 src/FileConventions.Test/DummyFiles/DummyCIWithUnpinnedNpmPackageInstallVersion.yml diff --git a/src/FileConventions.Test/DummyFiles/DummyCIWithUnpinnedNpmPackageInstallVersion.yml b/src/FileConventions.Test/DummyFiles/DummyCIWithUnpinnedNpmPackageInstallVersion.yml new file mode 100644 index 000000000..4f0e52c33 --- /dev/null +++ b/src/FileConventions.Test/DummyFiles/DummyCIWithUnpinnedNpmPackageInstallVersion.yml @@ -0,0 +1,11 @@ +name: CI + +on: [push, pull_request] + +jobs: + file-conventions: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install prettier without specifying its version + run: npm install prettier diff --git a/src/FileConventions.Test/FileConventions.Test.fs b/src/FileConventions.Test/FileConventions.Test.fs index 6b235486b..7ccc71797 100644 --- a/src/FileConventions.Test/FileConventions.Test.fs +++ b/src/FileConventions.Test/FileConventions.Test.fs @@ -154,6 +154,22 @@ let DetectUnpinnedDotnetToolInstallVersions2() = ) +[] +let DetectUnpinnedNpmPackageInstallVersions1() = + let fileInfo = + (FileInfo( + Path.Combine( + dummyFilesDirectory.FullName, + "DummyCIWithUnpinnedNpmPackageInstallVersion.yml" + ) + )) + + Assert.That( + DetectUnpinnedNpmPackageInstallVersions fileInfo, + Is.EqualTo true + ) + + [] let DetectAsteriskInPackageReferenceItems1() = let fileInfo = diff --git a/src/FileConventions/Library.fs b/src/FileConventions/Library.fs index c48a21ec9..5d165fef4 100644 --- a/src/FileConventions/Library.fs +++ b/src/FileConventions/Library.fs @@ -67,6 +67,9 @@ let DetectUnpinnedDotnetToolInstallVersions(fileInfo: FileInfo) = unpinnedDotnetToolInstallVersions +let DetectUnpinnedNpmPackageInstallVersions(fileInfo: FileInfo) = + false + let DetectAsteriskInPackageReferenceItems(fileInfo: FileInfo) = assert (fileInfo.FullName.EndsWith "proj") use streamReader = new StreamReader(fileInfo.FullName)