Skip to content

Commit

Permalink
Do not raise error when SQ status doesn't have tags defined (#132)
Browse files Browse the repository at this point in the history
* Do not raise error when SQ status doesn't have tags defined

* comment update
  • Loading branch information
msarvar authored Sep 28, 2021
1 parent 8c9fea7 commit f1d2f57
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
5 changes: 5 additions & 0 deletions server/events/vcs/github_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,11 @@ func (g *GithubClient) PullIsLocked(repo models.Repo, pull models.PullRequest, s
continue
}

// When Submit queue status does not have tags assume PR is not locked
if status.GetDescription() == "" {
return false, nil
}

// Not using struct tags because there's no predefined schema for description.
description := make(map[string]interface{})
err := json.Unmarshal([]byte(status.GetDescription()), &description)
Expand Down
29 changes: 29 additions & 0 deletions server/events/vcs/github_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1145,3 +1145,32 @@ func TestGithubClient_PullIsLocked_WaitingKeyNotFound(t *testing.T) {
Ok(t, err)
Equals(t, false, locked)
}

func TestGithubClient_PullIsLocked_SQ_No_Tags(t *testing.T) {
client, err := vcs.NewGithubClient("temp", &vcs.GithubUserCredentials{"user", "pass"}, logging.NewNoopLogger(t))
Ok(t, err)

statuses := []*github.RepoStatus{
{
Context: helper(vcs.SubmitQueueReadinessStatusContext),
Description: helper(""),
},
}

locked, err := client.PullIsLocked(models.Repo{
FullName: "owner/repo",
Owner: "owner",
Name: "repo",
CloneURL: "",
SanitizedCloneURL: "",
VCSHost: models.VCSHost{
Type: models.Github,
Hostname: "github.com",
},
}, models.PullRequest{
Num: 1,
HeadCommit: "832812d4777ddc4197685c5a8f864eaf8a82d4ae",
}, statuses)
Ok(t, err)
Equals(t, false, locked)
}

0 comments on commit f1d2f57

Please sign in to comment.