Skip to content

Commit a6ef9a7

Browse files
committed
test: add comprehensive unit tests for dependency_updater helper functions
- Add tests for generateGithubRepoUrl (valid + nil guard) - Add tests for writeToVersionsJson (success + invalid path) - Add tests for createVersionsEnv (basic, branch tracking, sorted output, invalid path) - Add tests for writeToGithubOutput (normal + missing env var) - Add tests for createCommitMessage in githubAction mode - Add tests for updateVersionTagAndCommit (in-memory + file write) - Add nil-safety guard to generateGithubRepoUrl for unknown keys Increases test coverage from 0 to 389 lines across 12 test functions.
1 parent 4e715e4 commit a6ef9a7

2 files changed

Lines changed: 394 additions & 1 deletion

File tree

dependency_updater/dependency_updater.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,5 +407,9 @@ func writeToGithubOutput(title string, description string, repoPath string) erro
407407
}
408408

409409
func generateGithubRepoUrl(dependencies Dependencies, dependencyType string) string {
410-
return "https://github.com/" + dependencies[dependencyType].Owner + "/" + dependencies[dependencyType].Repo
410+
info := dependencies[dependencyType]
411+
if info == nil {
412+
return ""
413+
}
414+
return "https://github.com/" + info.Owner + "/" + info.Repo
411415
}

0 commit comments

Comments
 (0)