cmd/repo-updater: add sync abort when user reached maximum allowed user added repos
Created by: sashaostrikov
This is my first piece of "production" Go code, so any number of comments is highly appreciated!
My main concern is about negative test (testSyncIsNotAbortedWhenThereIsNoLastError
).
I wanted to skip actual calls to DB, so I mocked everything I could, but I haven't found a way to mock the TransactableHandle so that the "fake" transaction can be opened and the sync will go all the way through without any errors. For now this test fails with an error * syncer: opening transaction: starting transaction: store: not transactable
and I just check that this error is not caused by my code which aborts the transaction, and therefore the test is green.
If anyone knows how to make this test pass without DB access and this error, please let me know.
Another thing is 1 linter error I don't know how to fix/suppress. I know for sure that there will be "\n", so I cannot get -1 from Index function
Error is as follows:
internal/repos/syncer.go:547:20: offBy1: Index() can return -1; maybe you wanted to do Index()+1 (gocritic)
syncErrorLine := syncErrorWithoutPrefix[:strings.Index(syncErrorWithoutPrefix, "
")]
^
Closes https://github.com/sourcegraph/sourcegraph/issues/28177