Skip to content

Commit

Permalink
Merge pull request #111 from prabenzom/timing-fix
Browse files Browse the repository at this point in the history
fix nil timing steps
  • Loading branch information
prabenzom authored May 26, 2021
2 parents b77fd43 + ac220ae commit 7b20b70
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
4 changes: 2 additions & 2 deletions bigquery/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,11 @@ func (n *bqNotifier) SendNotification(ctx context.Context, build *cbpb.Build) er
}

for _, step := range build.GetSteps() {
startTime, err := parsePBTime(step.Timing.StartTime)
startTime, err := parsePBTime(step.GetTiming().GetStartTime())
if err != nil {
return fmt.Errorf("error parsing start time for step: %v", err)
}
endTime, err := parsePBTime(step.Timing.EndTime)
endTime, err := parsePBTime(step.GetTiming().GetEndTime())
if err != nil {
return fmt.Errorf("error parsing end time for step: %v", err)
}
Expand Down
26 changes: 26 additions & 0 deletions bigquery/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,32 @@ func TestSendNotification(t *testing.T) {
},
wantErr: false,
wantRow: true,
}, {
name: "no build step timing",
cfg: &notifiers.Config{
Spec: &notifiers.Spec{
Notification: &notifiers.Notification{
Filter: `build.build_trigger_id == "123e4567-e89b-12d3-a456-426614174000" `,
Delivery: map[string]interface{}{
"table": "projects/project_name/datasets/dataset_name/tables/notinitialized",
},
},
},
},
build: &cbpb.Build{
ProjectId: "Project ID",
Id: "Build ID",
BuildTriggerId: "123e4567-e89b-12d3-a456-426614174000",
Status: cbpb.Build_SUCCESS,
CreateTime: timestamppb.Now(),
StartTime: timestamppb.Now(),
FinishTime: timestamppb.Now(),
Tags: []string{},
Steps: []*cbpb.BuildStep{{Name: "test"}},
Options: &cbpb.BuildOptions{Env: []string{}},
},
wantErr: true,
wantRow: false,
}, {
name: "table exists with bad schema",
cfg: &notifiers.Config{
Expand Down

0 comments on commit 7b20b70

Please sign in to comment.