🌱 e2e tests for cronjob

* Implemented basic e2e tests for cornjob
This commit is contained in:
naveen 2021-04-30 17:37:21 +00:00 committed by Naveen
parent cd7231dd75
commit 360d6b8381
4 changed files with 45 additions and 1 deletions

1
.gitignore vendored
View File

@ -17,6 +17,7 @@ scripts/update/projects-update
# Test binary, built with `go test -c`.
*.test
results.json
*.json
# Output of the go coverage tool, specifically when used with LiteIDE.
*.coverprofile*

View File

@ -72,7 +72,7 @@ unexport USE_BLOB_CACHE
ci-e2e: ## Runs ci e2e tests
.PHONY: ci-e2e
# export GITHUB_AUTH_TOKEN with personal access token to run the e2e
ci-e2e: build check-env
ci-e2e: build check-env e2e-cron
$(call ndef, GITHUB_AUTH_TOKEN)
@echo Ignoring these test for ci-e2e $(IGNORED_CI_TEST)
ginkgo -p -v -cover --skip=$(IGNORED_CI_TEST) ./e2e/...
@ -98,6 +98,9 @@ test-disk-cache: build ## Runs disk cache tests
--metadata=openssf --format json > ./$(OUTPUT)/results.json
USE_DISK_CACHE=1 DISK_CACHE_PATH="./cache" ginkgo -p -v -cover --focus=$(FOCUS_DISK_TEST) ./e2e/...
e2e-cron: ## validates cron
GCS_BUCKET=ossf-scorecards-dev go run ./cron/main.go ./e2e/cron-projects.txt
# Verification targets

3
e2e/cron-projects.txt Normal file
View File

@ -0,0 +1,3 @@
repo,metadata
github.com/ossf/scorecard,
github.com/ossf/criticality_score,

37
e2e/cron_test.go Normal file
View File

@ -0,0 +1,37 @@
// Copyright 2021 Security 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 e2e
import (
"fmt"
"io/ioutil"
"time"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("E2E TEST:cron", func() {
Context("E2E TEST:Validating cron test", func() {
It("Should return valid test results for cron", func() {
fileName := fmt.Sprintf("%02d-%02d-%d.json",
time.Now().Month(), time.Now().Day(), time.Now().Year())
_, err := ioutil.ReadFile("../" + fileName)
Expect(err).Should(BeNil())
// TODO - include validation to checks for file exists in the GCS bucket
})
})
})