Skip to content

Commit

Permalink
🌱 e2e for pinned_dependencies for localrepoclient
Browse files Browse the repository at this point in the history
- e2e for pinned_dependencies for localrepoclient

Signed-off-by: naveensrinivasan <[email protected]>
  • Loading branch information
naveensrinivasan committed Apr 5, 2022
1 parent b6b5592 commit 8113336
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions e2e/pinned_dependencies_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,18 @@ package e2e

import (
"context"
"io/ioutil"
"os"

"github.com/go-git/go-git/v5"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

"github.com/ossf/scorecard/v4/checker"
"github.com/ossf/scorecard/v4/checks"
"github.com/ossf/scorecard/v4/clients"
"github.com/ossf/scorecard/v4/clients/githubrepo"
"github.com/ossf/scorecard/v4/clients/localdir"
scut "github.com/ossf/scorecard/v4/utests"
)

Expand Down Expand Up @@ -80,5 +84,41 @@ var _ = Describe("E2E TEST:"+checks.CheckPinnedDependencies, func() {
Expect(scut.ValidateTestReturn(nil, "dependencies check", &expected, &result, &dl)).Should(BeTrue())
Expect(repoClient.Close()).Should(BeNil())
})
It("Should return dependencies check for a local repoClient", func() {
dl := scut.TestDetailLogger{}

tmpDir, err := ioutil.TempDir("", "")
Expect(err).Should(BeNil())
defer os.RemoveAll(tmpDir)

_, e := git.PlainClone(tmpDir, false, &git.CloneOptions{
URL: "http://github.com/ossf-tests/scorecard-check-pinned-dependencies-e2e",
})
Expect(e).Should(BeNil())

repo, err := localdir.MakeLocalDirRepo(tmpDir)
Expect(err).Should(BeNil())

x := localdir.CreateLocalDirClient(context.Background(), logger)
err = x.InitRepo(repo, clients.HeadSHA)
Expect(err).Should(BeNil())

req := checker.CheckRequest{
Ctx: context.Background(),
RepoClient: x,
Repo: repo,
Dlogger: &dl,
}
expected := scut.TestReturn{
Error: nil,
Score: 3,
NumberOfWarn: 139,
NumberOfInfo: 2,
NumberOfDebug: 0,
}
result := checks.PinnedDependencies(&req)
Expect(scut.ValidateTestReturn(nil, "dependencies check", &expected, &result, &dl)).Should(BeTrue())
Expect(x.Close()).Should(BeNil())
})
})
})

0 comments on commit 8113336

Please sign in to comment.