github.com/quay/claircore@v1.5.28/enricher/cvss/metafile_test.go (about)

     1  package cvss
     2  
     3  import (
     4  	"bytes"
     5  	"os"
     6  	"testing"
     7  	"time"
     8  
     9  	"github.com/google/go-cmp/cmp"
    10  )
    11  
    12  func TestMetafile(t *testing.T) {
    13  	in, err := os.Open("testdata/feed.meta")
    14  	if err != nil {
    15  		t.Fatal(err)
    16  	}
    17  	var buf bytes.Buffer
    18  	if _, err := buf.ReadFrom(in); err != nil {
    19  		t.Fatal(err)
    20  	}
    21  	want := metafile{
    22  		LastModified: time.Date(2021, time.June, 16, 3, 8, 30, 0, time.FixedZone("", -4*60*60)),
    23  		Size:         76353511,
    24  		ZipSize:      4070894,
    25  		GZSize:       4070758,
    26  		SHA256:       "708083B92E47F0B25C7DD68B89ECD9EF3F2EF91403F511AE13195A596F02E02E",
    27  	}
    28  	var got metafile
    29  	if err := got.Parse(&buf); err != nil {
    30  		t.Error(err)
    31  	}
    32  	if !cmp.Equal(&got, &want) {
    33  		t.Error(cmp.Diff(&got, &want))
    34  	}
    35  }