Files
steampipe/cmd/root_test.go
Nathan Wallace 79ab1c9b69 Fix #4707: Add nil check in hideRootFlags (#4880)
* Add test for #4707: hideRootFlags should handle non-existent flags

* Fix #4707: Add nil check in hideRootFlags
2025-11-15 11:16:53 -05:00

20 lines
571 B
Go

package cmd
import (
"testing"
"github.com/stretchr/testify/assert"
)
// TestHideRootFlags_NonExistentFlag tests that hideRootFlags handles non-existent flags gracefully
// Bug #4707: hideRootFlags panics when called with a flag that doesn't exist
func TestHideRootFlags_NonExistentFlag(t *testing.T) {
// Initialize the root command
InitCmd()
// Test that calling hideRootFlags with a non-existent flag should NOT panic
assert.NotPanics(t, func() {
hideRootFlags("non-existent-flag")
}, "hideRootFlags should handle non-existent flags without panicking")
}