github.com/yogeshkumararora/slsa-github-generator@v1.10.1-0.20240520161934-11278bd5afb4/internal/builders/go/pkg/provenance_test.go (about)

     1  // Copyright 2022 SLSA Authors
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package pkg
    16  
    17  import (
    18  	"testing"
    19  
    20  	"github.com/yogeshkumararora/slsa-github-generator/internal/testutil"
    21  	"github.com/yogeshkumararora/slsa-github-generator/slsa"
    22  )
    23  
    24  func TestGenerateProvenance_withErr(t *testing.T) {
    25  	// Disable pre-submit detection.
    26  	// TODO(github.com/yogeshkumararora/slsa-github-generator/issues/124): Remove
    27  	t.Setenv("GITHUB_EVENT_NAME", "non_event")
    28  	t.Setenv("GITHUB_CONTEXT", "{}")
    29  	sha256 := "2e0390eb024a52963db7b95e84a9c2b12c004054a7bad9a97ec0c7c89d4681d2"
    30  	_, err := GenerateProvenance(
    31  		"foo", sha256, "", "", "/home/foo",
    32  		&testutil.TestSigner{}, &testutil.TransparencyLogWithErr{},
    33  		&slsa.NilClientProvider{},
    34  	)
    35  	if want, got := testutil.ErrTransparencyLog, err; want != got {
    36  		t.Errorf("expected error, want: %v, got: %v", want, got)
    37  	}
    38  }