mirror of
https://github.com/ossf/scorecard.git
synced 2024-11-05 05:17:00 +03:00
🌱 e2e tests binary artifacts localrepo
- e2e tests for binary artifacts check for localrepo Signed-off-by: naveensrinivasan <172697+naveensrinivasan@users.noreply.github.com>
This commit is contained in:
parent
037a3f3516
commit
cacc3e486d
@ -16,7 +16,10 @@ package e2e
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
"github.com/go-git/go-git/v5"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
@ -24,6 +27,7 @@ import (
|
||||
"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"
|
||||
)
|
||||
|
||||
@ -173,5 +177,43 @@ var _ = Describe("E2E TEST:"+checks.CheckBinaryArtifacts, func() {
|
||||
Expect(scut.ValidateTestReturn(nil, "binary artifacts", &expected, &result, &dl)).Should(BeTrue())
|
||||
Expect(repoClient.Close()).Should(BeNil())
|
||||
})
|
||||
It("Should return binary artifacts present at commit in source code when using local repoClient", func() {
|
||||
// create temp dir
|
||||
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-binary-artifacts-e2e-4-binaries",
|
||||
})
|
||||
Expect(e).Should(BeNil())
|
||||
|
||||
dl := scut.TestDetailLogger{}
|
||||
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,
|
||||
}
|
||||
// TODO: upload real binaries to the repo as well.
|
||||
expected := scut.TestReturn{
|
||||
Error: nil,
|
||||
Score: checker.MaxResultScore - 4,
|
||||
NumberOfWarn: 4,
|
||||
NumberOfInfo: 0,
|
||||
NumberOfDebug: 0,
|
||||
}
|
||||
result := checks.BinaryArtifacts(&req)
|
||||
// New version.
|
||||
Expect(scut.ValidateTestReturn(nil, "binary artifacts", &expected, &result, &dl)).Should(BeTrue())
|
||||
Expect(x.Close()).Should(BeNil())
|
||||
})
|
||||
})
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user