Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Rockskip: add search tests#62581

Merged
jtibshirani merged 6 commits into
mainfrom
jtibs/rockskip
May 10, 2024
Merged

Rockskip: add search tests#62581
jtibshirani merged 6 commits into
mainfrom
jtibs/rockskip

Conversation

@jtibshirani

Copy link
Copy Markdown
Contributor

This commit adds integration tests for Rockskip symbol search. Specific changes:

  • Pull out mock objects and set-up logic from server_test.go into new file mock.go
  • Add new tests TestSearch and TestSearchResultLimiting

Test plan

Lots of new test cases!

@cla-bot cla-bot Bot added the cla-signed label May 9, 2024
@github-actions github-actions Bot added team/product-platform team/search-platform Issues owned by the search platform team labels May 9, 2024
@jtibshirani jtibshirani requested a review from a team May 9, 2024 18:46
Comment thread internal/rockskip/mocks.go
Comment on lines +94 to +108
// We don't use 'state' in this test, it's just needed for these method calls.
state := map[string][]string{}
gitAdd(t, repoDir, state, "a.txt", "sym1a\n")
gitAdd(t, repoDir, state, "b.txt", "sym1b\n")
gitRm(t, repoDir, state, "a.txt")

out, err := gitserver.CreateGitCommand(repoDir, "git", "rev-parse", "HEAD").CombinedOutput()
require.NoError(t, err, string(out))
commit1 := string(bytes.TrimSpace(out))

gitAdd(t, repoDir, state, "c.txt", "sym1c\nsym2c")
gitAdd(t, repoDir, state, "a.java", "sym1a\nsym2a")
gitAdd(t, repoDir, state, "b.java", "sym1b\nsym2b")
gitRm(t, repoDir, state, "a.java")
gitAdd(t, repoDir, state, "a.txt", "sym2a\nsym3a")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

quite a nice pattern from the go's internal testing is the idea of a testscript which makes this sort of code nicer to write. I am not sure if we can directly use it, since we seem to be more setting up to run the tests but maybe just use it as potential future idea :) It is copied out of internal and exposed here https://pkg.go.dev/github.com/rogpeppe/go-internal/testscript

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really nice! I'm not going to use this now but will keep it in mind for future refactors/ tests.

@jtibshirani jtibshirani merged commit 87f8776 into main May 10, 2024
@jtibshirani jtibshirani deleted the jtibs/rockskip branch May 10, 2024 17:27
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla-signed team/product-platform team/search-platform Issues owned by the search platform team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants