mirror of
https://github.com/lukaszraczylo/kportal.git
synced 2026-07-10 06:52:00 +00:00
style: Extract UI constants and refactor main view rendering (#30)
- [x] Add golangci-lint configuration with gocritic ifElseChain disabled
- [x] Rename error variables to avoid shadowing (createErr, watcherErr, watchErr, etc.)
- [x] Replace `interface{}` with `any` type alias throughout codebase
- [x] Add package-level documentation comments to all internal packages
- [x] Reorder struct fields alphabetically for consistency
- [x] Extract UI constants (terminal dimensions, column widths, colors) to constants.go
- [x] Refactor BubbleTeaUI main view rendering into smaller helper functions
- [x] Simplify nested conditionals and improve code clarity
- [x] Add `isForwardDisabled()` helper method to BubbleTeaUI
- [x] Update file permissions from 0644 to 0600 in config tests
- [x] Add `#nosec` comments and error suppression where appropriate
- [x] Improve test table struct field ordering for readability
- [x] Fix resource parsing in AddForward using strings.SplitN
- [x] Add comprehensive tests for new UI helper functions and constants
This commit is contained in:
@@ -82,13 +82,16 @@ func TestMessageTypes(t *testing.T) {
|
||||
}
|
||||
assert.Equal(t, 8080, availableMsg.port)
|
||||
assert.True(t, availableMsg.available)
|
||||
assert.Equal(t, "Port 8080 available", availableMsg.message)
|
||||
|
||||
unavailableMsg := PortCheckedMsg{
|
||||
port: 8080,
|
||||
available: false,
|
||||
message: "Port 8080 in use by process",
|
||||
}
|
||||
assert.Equal(t, 8080, unavailableMsg.port)
|
||||
assert.False(t, unavailableMsg.available)
|
||||
assert.Equal(t, "Port 8080 in use by process", unavailableMsg.message)
|
||||
})
|
||||
|
||||
t.Run("ForwardSavedMsg", func(t *testing.T) {
|
||||
@@ -117,10 +120,10 @@ func TestMessageTypes(t *testing.T) {
|
||||
t.Run("BenchmarkCompleteMsg", func(t *testing.T) {
|
||||
msg := BenchmarkCompleteMsg{
|
||||
ForwardID: "fwd-123",
|
||||
Results: nil,
|
||||
Error: nil,
|
||||
}
|
||||
assert.Equal(t, "fwd-123", msg.ForwardID)
|
||||
assert.Nil(t, msg.Results)
|
||||
assert.Nil(t, msg.Error)
|
||||
})
|
||||
|
||||
t.Run("BenchmarkProgressMsg", func(t *testing.T) {
|
||||
@@ -256,7 +259,7 @@ func TestRunBenchmarkCmd_Cancellation(t *testing.T) {
|
||||
|
||||
// Run with timeout to prevent hanging
|
||||
done := make(chan bool, 1)
|
||||
var msg interface{}
|
||||
var msg any
|
||||
go func() {
|
||||
msg = cmd()
|
||||
done <- true
|
||||
|
||||
Reference in New Issue
Block a user