Skip to content

Commit

Permalink
Merge pull request enterprise-contract#1539 from zregvart/pr/unit-tes…
Browse files Browse the repository at this point in the history
…t-no-network

Unit tests no network
  • Loading branch information
zregvart authored Apr 19, 2024
2 parents 2bb088d + 6f9bdaf commit 6048d47
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
run: |
git fetch origin "${GITHUB_BASE_REF:-$GITHUB_REF_NAME}"
git switch -c checks --track "origin/${GITHUB_BASE_REF:-$GITHUB_REF_NAME}"
trap "git switch - --detach" SIGINT
trap "git switch - --detach" EXIT
git rebase
if ! git diff --exit-code -s; then
for f in $(git diff --exit-code --name-only); do
Expand Down
1 change: 1 addition & 0 deletions cmd/validate/image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1194,6 +1194,7 @@ func TestEvaluatorLifecycle(t *testing.T) {
fmt.Sprintf(`{"publicKey": %s, "sources": [%s]}`, utils.TestPublicKeyJSON, strings.Join(sources, ", ")),
"--effective-time",
effectiveTimeTest,
"--ignore-rekor",
})

var out bytes.Buffer
Expand Down
5 changes: 5 additions & 0 deletions internal/image/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (

"github.com/google/go-containerregistry/pkg/name"
gcr "github.com/google/go-containerregistry/pkg/v1"
"github.com/google/go-containerregistry/pkg/v1/empty"
"github.com/google/go-containerregistry/pkg/v1/remote"
"github.com/google/go-containerregistry/pkg/v1/types"
"github.com/in-toto/in-toto-golang/in_toto"
Expand All @@ -46,6 +47,7 @@ import (
"github.com/enterprise-contract/ec-cli/internal/attestation"
"github.com/enterprise-contract/ec-cli/internal/evaluation_target/application_snapshot_image"
"github.com/enterprise-contract/ec-cli/internal/evaluator"
ecoci "github.com/enterprise-contract/ec-cli/internal/fetchers/oci"
"github.com/enterprise-contract/ec-cli/internal/fetchers/oci/fake"
"github.com/enterprise-contract/ec-cli/internal/policy"
"github.com/enterprise-contract/ec-cli/internal/utils"
Expand Down Expand Up @@ -316,6 +318,9 @@ func TestEvaluatorLifecycle(t *testing.T) {
signatures: []oci.Signature{validSignature},
attestations: []oci.Signature{validAttestation},
})
client := fake.FakeClient{}
client.On("Image", name.MustParseReference(imageRegistry+"@sha256:"+imageDigest), mock.Anything).Return(empty.Image, nil)
ctx = ecoci.WithClient(ctx, &client)

component := app.SnapshotComponent{
ContainerImage: imageRef,
Expand Down

0 comments on commit 6048d47

Please sign in to comment.