Skip to content

Commit

Permalink
Fixed Lint Issues
Browse files Browse the repository at this point in the history
- Fixed lint issues
- Renamed test function to TestLoadEnvelope

Signed-off-by: neilnaveen <[email protected]>
  • Loading branch information
neilnaveen committed Oct 26, 2023
1 parent a30a2ef commit 6de8947
Showing 1 changed file with 45 additions and 3 deletions.
48 changes: 45 additions & 3 deletions source/memory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
package source

import (
"context"
"encoding/json"
"fmt"
"reflect"
"testing"

Expand All @@ -25,10 +25,10 @@ import (
intoto "github.com/testifysec/go-witness/intoto"
)

func TestLoadFile(t *testing.T) {
func TestLoadEnvelope(t *testing.T) {
predicate, err := json.Marshal(attestation.Collection{})
if err != nil {
fmt.Errorf("failed to marshal predicate, err = %v", err)
t.Fatalf("failed to marshal predicate, err = %v", err)
}
tests := []struct {
name string
Expand Down Expand Up @@ -159,3 +159,45 @@ func TestLoadFile(t *testing.T) {
})
}
}

func TestMemorySource_Search(t *testing.T) {
type fields struct {
envelopesByReference map[string]CollectionEnvelope
referencesByCollectionName map[string][]string
subjectDigestsByReference map[string]map[string]struct{}
attestationsByReference map[string]map[string]struct{}
}
type args struct {
ctx context.Context
collectionName string
subjectDigests []string
attestations []string
}
tests := []struct {
name string
fields fields
args args
want []CollectionEnvelope
wantErr bool
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
s := &MemorySource{
envelopesByReference: tt.fields.envelopesByReference,
referencesByCollectionName: tt.fields.referencesByCollectionName,
subjectDigestsByReference: tt.fields.subjectDigestsByReference,
attestationsByReference: tt.fields.attestationsByReference,
}
got, err := s.Search(tt.args.ctx, tt.args.collectionName, tt.args.subjectDigests, tt.args.attestations)
if (err != nil) != tt.wantErr {
t.Errorf("MemorySource.Search() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("MemorySource.Search() = %v, want %v", got, tt.want)
}
})
}
}

0 comments on commit 6de8947

Please sign in to comment.