Skip to content

Commit

Permalink
Testing presubmit checks for when the go_proto is not updated.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 641242067
  • Loading branch information
erikvarga authored and copybara-github committed Jun 7, 2024
1 parent 6f5766c commit 0c5f5ec
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 30 deletions.
4 changes: 2 additions & 2 deletions binary/cli/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,15 +353,15 @@ func TestWriteScanResults(t *testing.T) {
ResultFile: filepath.Join(testDirPath, "result.textproto"),
},
wantFilename: "result.textproto",
wantContentPrefix: "version:",
wantContentPrefix: "scanner_version:",
},
{
desc: "Create proto using --output flag",
flags: &cli.Flags{
Output: []string{"textproto=" + filepath.Join(testDirPath, "result2.textproto")},
},
wantFilename: "result2.textproto",
wantContentPrefix: "version:",
wantContentPrefix: "scanner_version:",
},
{
desc: "Create SPDX 2.3",
Expand Down
14 changes: 7 additions & 7 deletions binary/proto/proto.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,13 @@ func ScanResultToProto(r *scalibr.ScanResult) (*spb.ScanResult, error) {
}

return &spb.ScanResult{
Version: r.Version,
StartTime: timestamppb.New(r.StartTime),
EndTime: timestamppb.New(r.EndTime),
Status: scanStatusToProto(r.Status),
PluginStatus: pluginStatus,
Inventories: inventories,
Findings: findings,
ScannerVersion: r.Version,

Check failure on line 169 in binary/proto/proto.go

View workflow job for this annotation

GitHub Actions / build-for-windows

unknown field ScannerVersion in struct literal of type scan_result_go_proto.ScanResult

Check failure on line 169 in binary/proto/proto.go

View workflow job for this annotation

GitHub Actions / build-for-linux

unknown field ScannerVersion in struct literal of type scan_result_go_proto.ScanResult
StartTime: timestamppb.New(r.StartTime),
EndTime: timestamppb.New(r.EndTime),
Status: scanStatusToProto(r.Status),
PluginStatus: pluginStatus,
Inventories: inventories,
Findings: findings,
}, nil
}

Expand Down
40 changes: 20 additions & 20 deletions binary/proto/proto_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import (

func TestWrite(t *testing.T) {
testDirPath := t.TempDir()
var result = &spb.ScanResult{Version: "1.0.0"}
var result = &spb.ScanResult{ScannerVersion: "1.0.0"}
testCases := []struct {
desc string
path string
Expand All @@ -51,7 +51,7 @@ func TestWrite(t *testing.T) {
{
desc: "textproto",
path: "output.textproto",
expectedPrefix: "version:",
expectedPrefix: "scanner_version:",
},
{
desc: "binproto",
Expand Down Expand Up @@ -104,7 +104,7 @@ func TestWrite_InvalidFilename(t *testing.T) {

func TestWriteWithFormat(t *testing.T) {
testDirPath := t.TempDir()
var result = &spb.ScanResult{Version: "1.0.0"}
var result = &spb.ScanResult{ScannerVersion: "1.0.0"}
testCases := []struct {
desc string
format string
Expand All @@ -113,7 +113,7 @@ func TestWriteWithFormat(t *testing.T) {
{
desc: "textproto",
format: "textproto",
expectedPrefix: "version:",
expectedPrefix: "scanner_version:",
},
{
desc: "binproto",
Expand Down Expand Up @@ -381,10 +381,10 @@ func TestScanResultToProto(t *testing.T) {
},
},
want: &spb.ScanResult{
Version: "1.0.0",
StartTime: timestamppb.New(startTime),
EndTime: timestamppb.New(endTime),
Status: successProto,
ScannerVersion: "1.0.0",
StartTime: timestamppb.New(startTime),
EndTime: timestamppb.New(endTime),
Status: successProto,
PluginStatus: []*spb.PluginStatus{
&spb.PluginStatus{
Name: "ext",
Expand Down Expand Up @@ -441,10 +441,10 @@ func TestScanResultToProto(t *testing.T) {
Inventories: []*extractor.Inventory{purlRPMInventory},
},
want: &spb.ScanResult{
Version: "1.0.0",
StartTime: timestamppb.New(startTime),
EndTime: timestamppb.New(endTime),
Status: successProto,
ScannerVersion: "1.0.0",
StartTime: timestamppb.New(startTime),
EndTime: timestamppb.New(endTime),
Status: successProto,
PluginStatus: []*spb.PluginStatus{
&spb.PluginStatus{
Name: "ext",
Expand Down Expand Up @@ -499,10 +499,10 @@ func TestScanResultToProto(t *testing.T) {
},
},
want: &spb.ScanResult{
Version: "1.0.0",
StartTime: timestamppb.New(startTime),
EndTime: timestamppb.New(endTime),
Status: successProto,
ScannerVersion: "1.0.0",
StartTime: timestamppb.New(startTime),
EndTime: timestamppb.New(endTime),
Status: successProto,
PluginStatus: []*spb.PluginStatus{
&spb.PluginStatus{
Name: "ext",
Expand Down Expand Up @@ -626,10 +626,10 @@ func TestScanResultToProto(t *testing.T) {
},
},
want: &spb.ScanResult{
Version: "1.0.0",
StartTime: timestamppb.New(startTime),
EndTime: timestamppb.New(endTime),
Status: failureProto,
ScannerVersion: "1.0.0",
StartTime: timestamppb.New(startTime),
EndTime: timestamppb.New(endTime),
Status: failureProto,
PluginStatus: []*spb.PluginStatus{
&spb.PluginStatus{
Name: "ext",
Expand Down
2 changes: 1 addition & 1 deletion binary/proto/scan_result.proto
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ option java_multiple_files = true;

// The software inventory and security findings that a scan run found.
message ScanResult {
string version = 1;
string scanner_version = 1;
google.protobuf.Timestamp start_time = 2;
google.protobuf.Timestamp end_time = 3;
// Status of the overall scan.
Expand Down

0 comments on commit 0c5f5ec

Please sign in to comment.