Fix make cover
While working on !130 (merged) I noticed that make cover
doesn't work as expected. It always return 0 coverage. This MR fixes this issue
Click to see the output before
❯ make cover
mkdir tmp
NOTE: make cover does not exit 1 on failure, don't use it to check for tests success!
PASS
coverage: 0.0% of statements
ok gitlab.com/gitlab-org/gitlab-elasticsearch-indexer 0.028s
=====> Total test coverage: <=====
gitlab.com/gitlab-org/gitlab-elasticsearch-indexer/main.go:30: main 0.0%
gitlab.com/gitlab-org/gitlab-elasticsearch-indexer/main.go:103: configureLogger 0.0%
gitlab.com/gitlab-org/gitlab-elasticsearch-indexer/main.go:112: generateCorrelationID 0.0%
total: (statements) 0.0%
Click to see the output after
❯ make cover
mkdir -p tmp
NOTE: make cover does not exit 1 on failure, don't use it to check for tests success!
ok gitlab.com/gitlab-org/gitlab-elasticsearch-indexer 19.972s coverage: 0.0% of statements
ok gitlab.com/gitlab-org/gitlab-elasticsearch-indexer/elastic 23.273s coverage: 82.7% of statements
ok gitlab.com/gitlab-org/gitlab-elasticsearch-indexer/git 21.131s coverage: 82.1% of statements
ok gitlab.com/gitlab-org/gitlab-elasticsearch-indexer/indexer 0.119s coverage: 75.0% of statements
=====> Total test coverage: <=====
gitlab.com/gitlab-org/gitlab-elasticsearch-indexer/elastic/client.go:35: FromEnv 50.0%
gitlab.com/gitlab-org/gitlab-elasticsearch-indexer/elastic/client.go:57: afterCallback 90.9%
gitlab.com/gitlab-org/gitlab-elasticsearch-indexer/elastic/client.go:80: NewClient 90.6%
gitlab.com/gitlab-org/gitlab-elasticsearch-indexer/elastic/client.go:159: ResolveAWSCredentials 100.0%
gitlab.com/gitlab-org/gitlab-elasticsearch-indexer/elastic/client.go:172: ParentID 100.0%
gitlab.com/gitlab-org/gitlab-elasticsearch-indexer/elastic/client.go:176: Flush 100.0%
gitlab.com/gitlab-org/gitlab-elasticsearch-indexer/elastic/client.go:186: Close 100.0%
gitlab.com/gitlab-org/gitlab-elasticsearch-indexer/elastic/client.go:190: Index 100.0%
gitlab.com/gitlab-org/gitlab-elasticsearch-indexer/elastic/client.go:202: Get 100.0%
gitlab.com/gitlab-org/gitlab-elasticsearch-indexer/elastic/client.go:211: GetCommit 100.0%
gitlab.com/gitlab-org/gitlab-elasticsearch-indexer/elastic/client.go:215: GetBlob 100.0%
gitlab.com/gitlab-org/gitlab-elasticsearch-indexer/elastic/client.go:219: Remove 100.0%
gitlab.com/gitlab-org/gitlab-elasticsearch-indexer/elastic/elastic.go:28: ReadConfig 87.5%
gitlab.com/gitlab-org/gitlab-elasticsearch-indexer/elastic/index.go:361: createIndex 80.0%
gitlab.com/gitlab-org/gitlab-elasticsearch-indexer/elastic/index.go:399: CreateWorkingIndex 100.0%
gitlab.com/gitlab-org/gitlab-elasticsearch-indexer/elastic/index.go:406: CreateBrokenIndex 0.0%
gitlab.com/gitlab-org/gitlab-elasticsearch-indexer/elastic/index.go:412: DeleteIndex 66.7%
gitlab.com/gitlab-org/gitlab-elasticsearch-indexer/git/gitaly.go:58: NewGitalyClient 85.7%
gitlab.com/gitlab-org/gitlab-elasticsearch-indexer/git/gitaly.go:125: ReadConfig 100.0%
gitlab.com/gitlab-org/gitlab-elasticsearch-indexer/git/gitaly.go:139: NewGitalyClientFromEnv 71.4%
gitlab.com/gitlab-org/gitlab-elasticsearch-indexer/git/gitaly.go:154: Close 0.0%
gitlab.com/gitlab-org/gitlab-elasticsearch-indexer/git/gitaly.go:158: EachFileChange 80.8%
gitlab.com/gitlab-org/gitlab-elasticsearch-indexer/git/gitaly.go:213: lookUpHEAD 75.0%
gitlab.com/gitlab-org/gitlab-elasticsearch-indexer/git/gitaly.go:231: findDefaultBranchName 80.0%
gitlab.com/gitlab-org/gitlab-elasticsearch-indexer/git/gitaly.go:243: getBlob 85.7%
gitlab.com/gitlab-org/gitlab-elasticsearch-indexer/git/gitaly.go:273: gitalyBuildFile 90.0%
gitlab.com/gitlab-org/gitlab-elasticsearch-indexer/git/gitaly.go:298: getBlobReader 100.0%
gitlab.com/gitlab-org/gitlab-elasticsearch-indexer/git/gitaly.go:302: EachCommit 81.2%
gitlab.com/gitlab-org/gitlab-elasticsearch-indexer/git/gitaly.go:343: GetLimitFileSize 0.0%
gitlab.com/gitlab-org/gitlab-elasticsearch-indexer/git/gitaly.go:347: gitalyBuildSignature 100.0%
gitlab.com/gitlab-org/gitlab-elasticsearch-indexer/git/gitaly.go:355: newContext 100.0%
gitlab.com/gitlab-org/gitlab-elasticsearch-indexer/indexer/blob.go:52: GenerateBlobID 100.0%
gitlab.com/gitlab-org/gitlab-elasticsearch-indexer/indexer/blob.go:60: hashStr 100.0%
gitlab.com/gitlab-org/gitlab-elasticsearch-indexer/indexer/blob.go:66: BuildBlob 85.7%
gitlab.com/gitlab-org/gitlab-elasticsearch-indexer/indexer/blob.go:120: DetectLanguage 100.0%
gitlab.com/gitlab-org/gitlab-elasticsearch-indexer/indexer/blob.go:132: DetectBinary 100.0%
gitlab.com/gitlab-org/gitlab-elasticsearch-indexer/indexer/commit.go:20: GenerateCommitID 100.0%
gitlab.com/gitlab-org/gitlab-elasticsearch-indexer/indexer/commit.go:24: BuildCommit 100.0%
gitlab.com/gitlab-org/gitlab-elasticsearch-indexer/indexer/encoding.go:15: NewEncoder 85.7%
gitlab.com/gitlab-org/gitlab-elasticsearch-indexer/indexer/encoding.go:28: tryEncodeString 60.0%
gitlab.com/gitlab-org/gitlab-elasticsearch-indexer/indexer/encoding.go:38: tryEncodeBytes 50.0%
gitlab.com/gitlab-org/gitlab-elasticsearch-indexer/indexer/encoding.go:49: encodeString 100.0%
gitlab.com/gitlab-org/gitlab-elasticsearch-indexer/indexer/encoding.go:54: encodeBytes 53.8%
gitlab.com/gitlab-org/gitlab-elasticsearch-indexer/indexer/indexer.go:25: NewIndexer 100.0%
gitlab.com/gitlab-org/gitlab-elasticsearch-indexer/indexer/indexer.go:33: submitCommit 100.0%
gitlab.com/gitlab-org/gitlab-elasticsearch-indexer/indexer/indexer.go:44: submitRepoBlob 100.0%
gitlab.com/gitlab-org/gitlab-elasticsearch-indexer/indexer/indexer.go:58: submitWikiBlob 0.0%
gitlab.com/gitlab-org/gitlab-elasticsearch-indexer/indexer/indexer.go:72: removeBlob 100.0%
gitlab.com/gitlab-org/gitlab-elasticsearch-indexer/indexer/indexer.go:79: indexCommits 100.0%
gitlab.com/gitlab-org/gitlab-elasticsearch-indexer/indexer/indexer.go:83: indexRepoBlobs 100.0%
gitlab.com/gitlab-org/gitlab-elasticsearch-indexer/indexer/indexer.go:87: indexWikiBlobs 0.0%
gitlab.com/gitlab-org/gitlab-elasticsearch-indexer/indexer/indexer.go:91: Flush 100.0%
gitlab.com/gitlab-org/gitlab-elasticsearch-indexer/indexer/indexer.go:95: IndexBlobs 50.0%
gitlab.com/gitlab-org/gitlab-elasticsearch-indexer/indexer/indexer.go:106: IndexCommits 50.0%
gitlab.com/gitlab-org/gitlab-elasticsearch-indexer/indexer/person.go:19: GenerateDate 100.0%
gitlab.com/gitlab-org/gitlab-elasticsearch-indexer/indexer/person.go:23: BuildPerson 100.0%
gitlab.com/gitlab-org/gitlab-elasticsearch-indexer/main.go:30: main 0.0%
gitlab.com/gitlab-org/gitlab-elasticsearch-indexer/main.go:103: configureLogger 0.0%
gitlab.com/gitlab-org/gitlab-elasticsearch-indexer/main.go:112: generateCorrelationID 0.0%
total: (statements) 69.0%
Edited by Dmitry Gruzd