-
Notifications
You must be signed in to change notification settings - Fork 119
Fix databricks labs list to include all projects
#3935
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
7a5136c
Fix trivial spelling mistakes.
asnare df3d92f
Fix enumeration of the Databricks Labs projects.
asnare b315701
Update the pagination size from the default (30) to 100.
asnare 19a494e
Merge branch 'databricks:main' into fix/labs-list-pagination
asnare a4a43b6
Merge branch 'main' into fix/labs-list-pagination
asnare 4aa6c9e
Merge branch 'main' into fix/labs-list-pagination
asnare d4afeb9
Add a link to the GH docs on pagination.
asnare b51f62d
Check for the <> around the URL and slice instead of just trimming.
asnare 3d57e78
Unit tests for link-header parsing.
asnare 42628f3
Merge branch 'main' into fix/labs-list-pagination
asnare File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| package github | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/assert" | ||
| ) | ||
|
|
||
| func TestParseNextLink(t *testing.T) { | ||
| tests := []struct { | ||
| name string | ||
| linkHeader string | ||
| expected string | ||
| }{ | ||
| // First and foremost, the well-formed cases that we can expect from real GitHub API. | ||
| { | ||
| name: "no header", | ||
| linkHeader: "", | ||
| expected: "", | ||
| }, | ||
| { | ||
| name: "documentation example", | ||
| linkHeader: `<https://api.github.com/repositories/1300192/issues?page=2>; rel="prev", <https://api.github.com/repositories/1300192/issues?page=4>; rel="next", <https://api.github.com/repositories/1300192/issues?page=515>; rel="last", <https://api.github.com/repositories/1300192/issues?page=1>; rel="first"`, | ||
| expected: "https://api.github.com/repositories/1300192/issues?page=4", | ||
| }, | ||
| { | ||
| name: "with next only", | ||
| linkHeader: `<https://api.github.com/repos/databricks/cli/issues?page=2>; rel="next"`, | ||
| expected: "https://api.github.com/repos/databricks/cli/issues?page=2", | ||
| }, | ||
| { | ||
| name: "without next", | ||
| linkHeader: `<https://api.github.com/repositories/1300192/issues?page=1>; rel="prev", <https://api.github.com/repositories/1300192/issues?page=1>; rel="first", <https://api.github.com/repositories/1300192/issues?page=515>; rel="last"`, | ||
| expected: "", | ||
| }, | ||
| { | ||
| name: "next at beginning", | ||
| linkHeader: `<https://api.github.com/repos/test/test?page=5>; rel="next", <https://api.github.com/repos/test/test?page=10>; rel="last"`, | ||
| expected: "https://api.github.com/repos/test/test?page=5", | ||
| }, | ||
| { | ||
| name: "next at end", | ||
| linkHeader: `<https://api.github.com/repos/test/test?page=10>; rel="last", <https://api.github.com/repos/test/test?page=5>; rel="next"`, | ||
| expected: "https://api.github.com/repos/test/test?page=5", | ||
| }, | ||
| // Malformed cases to ensure robustness. (These should not occur in practice, but are here to demonstrate resilience.) | ||
| { | ||
| name: "malformed no semicolon", | ||
| linkHeader: `<https://api.github.com/repos/test/test?page=2> rel="next"`, | ||
| expected: "", | ||
| }, | ||
| { | ||
| name: "malformed no angle-brackets", | ||
| linkHeader: `https://api.github.com/repos/test/test?page=2; rel="next"`, | ||
| expected: "", | ||
| }, | ||
| { | ||
| name: "malformed multiple parts", | ||
| linkHeader: `<https://api.github.com/repos/test/test?page=2>; rel="next"; extra="value"`, | ||
| expected: "", | ||
| }, | ||
| { | ||
| name: "malformed no url", | ||
| linkHeader: `<>; rel="next"`, | ||
| expected: "", | ||
| }, | ||
| { | ||
| name: "malformed empty link", | ||
| linkHeader: `, <https://api.github.com/repos/test/test?page=5>; rel="next"`, | ||
| expected: "https://api.github.com/repos/test/test?page=5", | ||
| }, | ||
| // Borderline case: some tolerance of whitespace. | ||
| { | ||
| name: "tolerate whitespace", | ||
| linkHeader: ` <https://api.github.com/repos/test/test?page=2> ; rel="next" `, | ||
| expected: "https://api.github.com/repos/test/test?page=2", | ||
| }, | ||
| } | ||
|
|
||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| result := parseNextLink(tt.linkHeader) | ||
| assert.Equal(t, tt.expected, result) | ||
| }) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.