Skip to content

Commit

Permalink
add test for skip and top arguments in azuredevops /diffs endpoint
Browse files Browse the repository at this point in the history
Signed-off-by: Petr Bubenik <[email protected]>
  • Loading branch information
Petr Bubenik committed Feb 4, 2025
1 parent f7332b2 commit ab8665c
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions server/events/vcs/azuredevops_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,11 @@ func TestAzureDevopsClient_GetModifiedFiles(t *testing.T) {
// We write a header that means there's an additional page.
w.Write([]byte(resp)) // nolint: errcheck
return
// The third url for test of arguments skip and top in diff endpoint
case "/owner/project/_apis/git/repositories/repo/diffs/commits?%24skip=456&%24top=123&api-version=5.1&baseVersion=new_feature&targetVersion=npaulk%2Fmy_work":
// We write a header that means there's an additional page.
w.Write([]byte(resp)) // nolint: errcheck
return
default:
t.Errorf("got unexpected request at %q", r.RequestURI)
http.Error(w, "not found", http.StatusNotFound)
Expand Down Expand Up @@ -307,6 +312,29 @@ func TestAzureDevopsClient_GetModifiedFiles(t *testing.T) {
})
Ok(t, err)
Equals(t, []string{"file1.txt", "file2.txt"}, files)

// Redefined client for test of top and skip arguments in azuredevops diffs endpoint
client, err = vcs.NewAzureDevopsClient(testServerURL.Host, "user", "token", vcs.WithDiffTop(123), vcs.WithDiffSkip(456))
Ok(t, err)
defer disableSSLVerification()()

files, err = client.GetModifiedFiles(
logger,
models.Repo{
FullName: "owner/project/repo",
Owner: "owner",
Name: "repo",
CloneURL: "",
SanitizedCloneURL: "",
VCSHost: models.VCSHost{
Type: models.AzureDevops,
Hostname: "dev.azure.com",
},
}, models.PullRequest{
Num: 1,
})
Ok(t, err)
Equals(t, []string{"file1.txt", "file2.txt"}, files)
}

func TestAzureDevopsClient_PullIsMergeable(t *testing.T) {
Expand Down

0 comments on commit ab8665c

Please sign in to comment.