github.com/gitbundle/modules@v0.0.0-20231025071548-85b91c5c3b01/git/repo_language_stats_test.go (about) 1 // Copyright 2023 The GitBundle Inc. All rights reserved. 2 // Copyright 2017 The Gitea Authors. All rights reserved. 3 // Use of this source code is governed by a MIT-style 4 // license that can be found in the LICENSE file. 5 6 //go:build !gogit 7 8 package git 9 10 import ( 11 "path/filepath" 12 "testing" 13 14 "github.com/stretchr/testify/assert" 15 ) 16 17 func TestRepository_GetLanguageStats(t *testing.T) { 18 repoPath := filepath.Join(testReposDir, "language_stats_repo") 19 gitRepo, err := openRepositoryWithDefaultContext(repoPath) 20 if !assert.NoError(t, err) { 21 t.Fatal() 22 } 23 defer gitRepo.Close() 24 25 stats, err := gitRepo.GetLanguageStats("8fee858da5796dfb37704761701bb8e800ad9ef3") 26 if !assert.NoError(t, err) { 27 t.Fatal() 28 } 29 30 assert.EqualValues(t, map[string]int64{ 31 "Python": 134, 32 "Java": 112, 33 }, stats) 34 }