Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2022-08-09 15:10:17 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2022-08-09 15:15:47 +0300
commit2bcafb150113cc51f91d05f78da684eada42fa33 (patch)
tree5a78b7959a26ef2b7b3752c308681f95340c9436
parent9765a9733ed7f433d0241a589b45bbf712b1a0ab (diff)
STYLE.md: Discourage the use of seed repos for test datapks-doc-discourage-seeded-test-repos
With the upcoming transition to start supporting the SHA256 object hash in our repositories we will have to amend our tests to support both SHA1 and SHA256 object hashes. Due to our use of static seed repositories in many of our tests though this proving to be quite a burden as we have an abundance of hardcoded SHA1 hashes. Discourage the use of seed repositories in favor of generating the data at runtime instead with our test helpers. This gives us agility when the object format of a repository changes as we don't depend on hardcoded information anymore, but in many cases it also speeds up test execution as we don't have to clone thousands of repositories on every test run anymore. Last but not least this also helps readers understand tests better given that they don't have to peek into the seed repositories to get an understanding of how the test data is arranged, but instead can learn about it by just reading through the now-explicit test data setup.
-rw-r--r--STYLE.md15
1 files changed, 15 insertions, 0 deletions
diff --git a/STYLE.md b/STYLE.md
index fbf61a061..667973ee5 100644
--- a/STYLE.md
+++ b/STYLE.md
@@ -243,6 +243,21 @@ tests are supposed to set up required state as part of the tests themselves. All
`TestMain()` functions must call `testhelper.Run()` though, which performs the
setup of global state required for tests.
+### Test data
+
+Tests should not rely on static Git data but instead generate test data at
+runtime if possible. This is done so that we can easily adapt to changes in
+Git's repository or object format, e.g. in the transition from the SHA1 to the
+SHA256 object hash. Using seed repositories is thus discouraged.
+
+As an alternative, tests can rely on the following helper functions to generate
+their test data:
+
+- `gittest.WriteCommit()`
+- `gittest.WriteTree()`
+- `gittest.WriteBlob()`
+- `gittest.WriteTag()`
+
## Black box and white box testing
The dominant style of testing in Gitaly is "white box" testing, meaning