@@ -15,14 +15,18 @@ package e2e
1515
1616import (
1717 "context"
18+ "io/ioutil"
19+ "os"
1820
21+ "github.com/go-git/go-git/v5"
1922 . "github.com/onsi/ginkgo/v2"
2023 . "github.com/onsi/gomega"
2124
2225 "github.com/ossf/scorecard/v4/checker"
2326 "github.com/ossf/scorecard/v4/checks"
2427 "github.com/ossf/scorecard/v4/clients"
2528 "github.com/ossf/scorecard/v4/clients/githubrepo"
29+ "github.com/ossf/scorecard/v4/clients/localdir"
2630 scut "github.com/ossf/scorecard/v4/utests"
2731)
2832
@@ -80,5 +84,41 @@ var _ = Describe("E2E TEST:"+checks.CheckPinnedDependencies, func() {
8084 Expect (scut .ValidateTestReturn (nil , "dependencies check" , & expected , & result , & dl )).Should (BeTrue ())
8185 Expect (repoClient .Close ()).Should (BeNil ())
8286 })
87+ It ("Should return dependencies check for a local repoClient" , func () {
88+ dl := scut.TestDetailLogger {}
89+
90+ tmpDir , err := ioutil .TempDir ("" , "" )
91+ Expect (err ).Should (BeNil ())
92+ defer os .RemoveAll (tmpDir )
93+
94+ _ , e := git .PlainClone (tmpDir , false , & git.CloneOptions {
95+ URL : "http://github.com/ossf-tests/scorecard-check-pinned-dependencies-e2e" ,
96+ })
97+ Expect (e ).Should (BeNil ())
98+
99+ repo , err := localdir .MakeLocalDirRepo (tmpDir )
100+ Expect (err ).Should (BeNil ())
101+
102+ x := localdir .CreateLocalDirClient (context .Background (), logger )
103+ err = x .InitRepo (repo , clients .HeadSHA )
104+ Expect (err ).Should (BeNil ())
105+
106+ req := checker.CheckRequest {
107+ Ctx : context .Background (),
108+ RepoClient : x ,
109+ Repo : repo ,
110+ Dlogger : & dl ,
111+ }
112+ expected := scut.TestReturn {
113+ Error : nil ,
114+ Score : 3 ,
115+ NumberOfWarn : 139 ,
116+ NumberOfInfo : 2 ,
117+ NumberOfDebug : 0 ,
118+ }
119+ result := checks .PinnedDependencies (& req )
120+ Expect (scut .ValidateTestReturn (nil , "dependencies check" , & expected , & result , & dl )).Should (BeTrue ())
121+ Expect (x .Close ()).Should (BeNil ())
122+ })
83123 })
84124})
0 commit comments