Skip to content

Commit

Permalink
🌱 e2e for licenses (#3177)
Browse files Browse the repository at this point in the history
* 🌱 e2e for licenses

- e2e for licenses

Signed-off-by: naveensrinivasan <172697+naveensrinivasan@users.noreply.github.com>

* Code review comments.

Signed-off-by: naveensrinivasan <172697+naveensrinivasan@users.noreply.github.com>

---------

Signed-off-by: naveensrinivasan <172697+naveensrinivasan@users.noreply.github.com>
  • Loading branch information
naveensrinivasan committed Jun 21, 2023
1 parent 20b4aab commit b4c197c
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions clients/githubrepo/licenses_e2e_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// Copyright 2023 OpenSSF Scorecard Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package githubrepo

import (
"context"
"net/http"

"github.com/google/go-github/v38/github"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

"github.com/ossf/scorecard/v4/clients"
"github.com/ossf/scorecard/v4/clients/githubrepo/roundtripper"
"github.com/ossf/scorecard/v4/log"
)

var _ = Describe("E2E TEST: githubrepo.licensesHandler", func() {
var lh *licensesHandler

BeforeEach(func() {
ctx := context.Background()
rt := roundtripper.NewTransport(context.Background(), &log.Logger{})
httpClient := &http.Client{
Transport: rt,
}
client := github.NewClient(httpClient)
lh = &licensesHandler{
ghclient: client,
ctx: ctx,
}
})
Context("listLicenses()", func() {
It("returns licenses", func() {
repoURL := repoURL{
owner: "ossf",
repo: "scorecard",
commitSHA: clients.HeadSHA,
}

lh.init(context.Background(), &repoURL)
licenses, err := lh.listLicenses()
Expect(err).NotTo(HaveOccurred())
Expect(lh.errSetup).Should(BeNil())
Expect(len(licenses)).Should(Equal(1))
Expect(licenses[0].Name).Should(Equal("Apache License 2.0"))
Expect(licenses[0].Path).Should(Equal("LICENSE"))
})
})
})

0 comments on commit b4c197c

Please sign in to comment.