Skip to content

Commit

Permalink
PR comments
Browse files Browse the repository at this point in the history
Signed-off-by: Jamie Magee <[email protected]>
  • Loading branch information
JamieMagee committed Dec 4, 2024
1 parent 75b3bf2 commit a8af2db
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 7 deletions.
1 change: 1 addition & 0 deletions clients/azuredevopsrepo/languages.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func (l *languagesHandler) init(ctx context.Context, repourl *Repo) {
l.repourl = repourl
l.languages = []clients.Language{}
l.projectAnalysis = l.projectAnalysisClient.GetProjectLanguageAnalytics
l.errSetup = nil

Check warning on line 43 in clients/azuredevopsrepo/languages.go

View check run for this annotation

Codecov / codecov/patch

clients/azuredevopsrepo/languages.go#L37-L43

Added lines #L37 - L43 were not covered by tests
}

type (
Expand Down
33 changes: 33 additions & 0 deletions clients/azuredevopsrepo/languages_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,39 @@ func Test_listProgrammingLanguages(t *testing.T) {
},
wantErr: false,
},
{
name: "multiple response",
projectAnalysis: func(ctx context.Context, args projectanalysis.GetProjectLanguageAnalyticsArgs) (*projectanalysis.ProjectLanguageAnalytics, error) {
return &projectanalysis.ProjectLanguageAnalytics{
RepositoryLanguageAnalytics: &[]projectanalysis.RepositoryLanguageAnalytics{
{
Id: toPtr(uuid.Nil),
LanguageBreakdown: &[]projectanalysis.LanguageStatistics{
{
Name: toPtr("test1"),
LanguagePercentage: toPtr(float64(50)),
},
{
Name: toPtr("test2"),
LanguagePercentage: toPtr(float64(50)),
},
},
},
},
}, nil
},
want: []clients.Language{
{
Name: "test1",
NumLines: 50,
},
{
Name: "test2",
NumLines: 50,
},
},
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
11 changes: 4 additions & 7 deletions clients/azuredevopsrepo/zip.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,17 +174,14 @@ func (z *zipHandler) extractZip() error {
return errInvalidFilePath
}

if file.FileInfo().IsDir() {
if err := os.MkdirAll(filenamepath, 0o755); err != nil {
return fmt.Errorf("error during os.MkdirAll: %w", err)
}
continue
}

if err := os.MkdirAll(filepath.Dir(filenamepath), 0o755); err != nil {
return fmt.Errorf("error during os.MkdirAll: %w", err)
}

Check warning on line 179 in clients/azuredevopsrepo/zip.go

View check run for this annotation

Codecov / codecov/patch

clients/azuredevopsrepo/zip.go#L178-L179

Added lines #L178 - L179 were not covered by tests

if file.FileInfo().IsDir() {
continue
}

outFile, err := os.OpenFile(filenamepath, os.O_CREATE|os.O_WRONLY, 0o644)
if err != nil {
return fmt.Errorf("os.OpenFile: %w", err)
Expand Down

0 comments on commit a8af2db

Please sign in to comment.