Skip to content

Add edge case tests for mask function boundary conditions#140

Merged
yegor256 merged 2 commits into
138.afrom
copilot/sub-pr-139
Dec 13, 2025
Merged

Add edge case tests for mask function boundary conditions#140
yegor256 merged 2 commits into
138.afrom
copilot/sub-pr-139

Conversation

Copilot AI commented Dec 13, 2025

Copy link
Copy Markdown
Contributor

Addresses feedback on PR #139 to add missing edge case tests for the mask function, which masks API tokens by showing the first 3 characters and replacing the rest with asterisks.

Changes

  • Added test for single-character token (length 1): Verifies token remains fully visible
  • Added test for three-character token (length 3): Tests boundary where visible length equals token length
  • Added test for four-character token (length 4): Tests first case where masking occurs with one asterisk

These tests cover critical boundary conditions in the masking logic:

func mask(token string) string {
    n := len(token)
    if n == 0 {
        return ""
    }
    visible := min(n, 3)
    return token[:visible] + strings.Repeat("*", n-visible)
}

The new tests ensure correct behavior at the transition points where the function switches from no masking (≤3 chars) to progressive masking (>3 chars).


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: yegor256 <526301+yegor256@users.noreply.github.com>
Copilot AI changed the title [WIP] WIP address feedback on new test for params.go Add edge case tests for mask function boundary conditions Dec 13, 2025
Copilot AI requested a review from yegor256 December 13, 2025 05:31
@yegor256 yegor256 marked this pull request as ready for review December 13, 2025 05:34
Copilot AI review requested due to automatic review settings December 13, 2025 05:34
@yegor256 yegor256 merged commit 4b9f911 into 138.a Dec 13, 2025

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adds comprehensive edge case tests for the mask function to ensure correct behavior at critical boundary conditions. The mask function is used to safely display API tokens in logs by showing only the first 3 characters and replacing the rest with asterisks.

  • Adds three new test cases covering lengths 1, 3, and 4 characters
  • Tests the transition point where masking begins (tokens with more than 3 characters)
  • Complements existing tests for empty strings, 2-character tokens, and long tokens

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants