test(random): add unit tests for random behavior
SonarQube Scan / SonarQube Trigger (push) Successful in 1m37s

- Added unit tests to cover random string generation and error handling.
- Introduced Random interface and random struct for better abstraction.
- Updated server, session, and interaction packages to require Random interface for dependency injection.
This commit is contained in:
2026-01-22 13:27:25 +07:00
parent ae31e573b5
commit 9d03f5507f
8 changed files with 109 additions and 14 deletions
+1 -2
View File
@@ -3,7 +3,6 @@ package interaction
import (
"fmt"
"strings"
"tunnel_pls/internal/random"
"tunnel_pls/types"
"github.com/charmbracelet/bubbles/key"
@@ -47,7 +46,7 @@ func (m *model) slugUpdate(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
return m, tea.Batch(tea.ClearScreen, textinput.Blink)
default:
if key.Matches(msg, m.keymap.random) {
newSubdomain, err := random.GenerateRandomString(20)
newSubdomain, err := m.randomizer.String(20)
if err != nil {
return m, cmd
}