Skip to content

test: Add unit tests for documentation generation#597

Merged
bupd merged 2 commits into
goharbor:mainfrom
rkcoder101:test/doc
Jan 22, 2026
Merged

test: Add unit tests for documentation generation#597
bupd merged 2 commits into
goharbor:mainfrom
rkcoder101:test/doc

Conversation

@rkcoder101

@rkcoder101 rkcoder101 commented Jan 17, 2026

Copy link
Copy Markdown
Contributor

Description

This PR introduces unit tests for the documentation generation utility (doc/doc.go and doc/man-docs/man_doc.go).

Relates to #591

Test Coverage Checklist

The following functions in doc.go are targeted for unit tests:

  • preblock
  • printOptions
  • MarkdownCustom
  • linkHandler
  • hasSeeAlso
  • getWeight
  • MarkdownCustomTree
  • Docs

The following functions in man_doc.go are targeted for unit tests:

  • ManDoc
  • cleanManPages

@codecov

codecov Bot commented Jan 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 7.17%. Comparing base (60ad0bd) to head (5f4ae3e).
⚠️ Report is 81 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##             main    #597      +/-   ##
=========================================
- Coverage   10.99%   7.17%   -3.82%     
=========================================
  Files         173     260      +87     
  Lines        8671   12845    +4174     
=========================================
- Hits          953     922      -31     
- Misses       7612   11815    +4203     
- Partials      106     108       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bupd bupd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Linter Issues

Running golangci-lint run ./doc/... reveals issues that need to be fixed:

  1. Missing license header (goheader):

    doc/doc_test.go:1:1: Missed header for check
    

    Add the Apache 2.0 license header at the top of doc_test.go.

  2. File permissions (gosec - 3 occurrences):

    doc/doc_test.go:130, 152, 166: G306: Expect WriteFile permissions to be 0600 or less
    

    Change os.WriteFile(..., 0644) to os.WriteFile(..., 0600) in all test cases.

  3. Whitespace issue:

    doc/doc_test.go:231: unnecessary leading newline
    

    Remove the blank line after func TestPreblock(t *testing.T) {.

@bupd bupd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rkcoder101 Thanks for your contribution

Please fix the lint issues - https://github.com/goharbor/harbor-cli/actions/runs/21089411887/attempts/1#summary-60658461489

otherwise /lgtm

@bupd bupd added go Pull requests that update go code Changes Requesed feedback that must be addressed before merging. labels Jan 17, 2026
@rkcoder101

Copy link
Copy Markdown
Contributor Author

@bupd Thanks for the review, I have taken care of the linting issues in the latest commit.

@rkcoder101 rkcoder101 requested a review from bupd January 19, 2026 15:56
@bupd

bupd commented Jan 21, 2026

Copy link
Copy Markdown
Member

@rkcoder101 please rebase onto the main branch.

@bupd bupd marked this pull request as ready for review January 21, 2026 22:25
@bupd bupd self-assigned this Jan 21, 2026
…ock functions of doc.go. Did some very minor changes in doc.go wherever required

Signed-off-by: Rayyan Khan <rayyanrehman101@gmail.com>
…f doc.go. Did some very minor changes in doc.go wherever required

Signed-off-by: Rayyan Khan <rayyanrehman101@gmail.com>

@bupd bupd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@bupd bupd merged commit 4897b35 into goharbor:main Jan 22, 2026
7 of 8 checks passed
Vickysomtee pushed a commit to Vickysomtee/harbor-cli that referenced this pull request Feb 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Changes Requesed feedback that must be addressed before merging. go Pull requests that update go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants