// retrieveRoll obtains the given DEPS roll from Rietveld. func (r *AutoRoller) retrieveRoll(issueNum int64) (*autoroll.AutoRollIssue, error) { issue, err := r.rietveld.GetIssueProperties(issueNum, true) if err != nil { return nil, err } a, err := autoroll.FromRietveldIssue(issue, r.rm.FullSkiaHash) if err != nil { return nil, err } tryResults, err := autoroll.GetTryResults(r.rietveld, a) if err != nil { return nil, err } a.TryResults = tryResults return a, nil }
// retrieveRoll obtains the given DEPS roll from Rietveld. func (r *AutoRoller) retrieveRoll(issueNum int64) (*autoroll.AutoRollIssue, error) { issue, err := r.rietveld.GetIssueProperties(issueNum, true) if err != nil { return nil, fmt.Errorf("Failed to get issue properties: %s", err) } a, err := autoroll.FromRietveldIssue(issue, r.rm.FullChildHash) if err != nil { return nil, fmt.Errorf("Failed to convert issue format: %s", err) } tryResults, err := autoroll.GetTryResults(r.rietveld, a) if err != nil { return nil, fmt.Errorf("Failed to retrieve try results: %s", err) } a.TryResults = tryResults return a, nil }
// checkStatus verifies that we get the expected status from the roller. func checkStatus(t *testing.T, r *AutoRoller, rv *mockRietveld, rm *mockRepoManager, expectedStatus string, current *rietveld.Issue, currentTrybots []*buildbucket.Build, currentDryRun bool, last *rietveld.Issue, lastTrybots []*buildbucket.Build, lastDryRun bool) { rv.assertMocksEmpty() rm.assertForceUpdate() s := r.GetStatus(true) assert.Equal(t, expectedStatus, s.Status) assert.Equal(t, s.Error, "") checkRoll := func(t *testing.T, expect *rietveld.Issue, actual *autoroll.AutoRollIssue, expectTrybots []*buildbucket.Build, dryRun bool) { if expect != nil { assert.NotNil(t, actual) ari, err := autoroll.FromRietveldIssue(expect, rm.FullSkiaHash) assert.Nil(t, err) tryResults := make([]*autoroll.TryResult, 0, len(expectTrybots)) for _, b := range expectTrybots { tryResult, err := autoroll.TryResultFromBuildbucket(b) assert.Nil(t, err) tryResults = append(tryResults, tryResult) } ari.TryResults = tryResults // This is kind of a hack to prevent having to pass the // expected dry run result around. if dryRun { if ari.AllTrybotsFinished() { ari.Result = autoroll.ROLL_RESULT_DRY_RUN_FAILURE if ari.AllTrybotsSucceeded() { ari.Result = autoroll.ROLL_RESULT_DRY_RUN_SUCCESS } } } assert.Nil(t, ari.Validate()) testutils.AssertDeepEqual(t, ari, actual) } else { assert.Nil(t, actual) } } checkRoll(t, current, s.CurrentRoll, currentTrybots, currentDryRun) checkRoll(t, last, s.LastRoll, lastTrybots, lastDryRun) }