@@ -22,10 +22,8 @@ func TestLooksLikeUUID_resourceName(t *testing.T) {
2222
2323func TestListPipelinesTableConfig (t * testing.T ) {
2424 cmd := newListPipelines ()
25- cmd .SetContext (t .Context ())
26- require .NoError (t , cmd .PreRunE (cmd , nil ))
2725
28- cfg := tableview .GetTableConfig (cmd . Context () )
26+ cfg := tableview .GetTableConfigForCmd (cmd )
2927 require .NotNil (t , cfg )
3028 require .Len (t , cfg .Columns , 3 )
3129 require .NotNil (t , cfg .Search )
@@ -43,10 +41,8 @@ func TestListPipelinesTableConfig(t *testing.T) {
4341
4442func TestListPipelinesSearchEscapesLikeWildcards (t * testing.T ) {
4543 cmd := newListPipelines ()
46- cmd .SetContext (t .Context ())
47- require .NoError (t , cmd .PreRunE (cmd , nil ))
4844
49- cfg := tableview .GetTableConfig (cmd . Context () )
45+ cfg := tableview .GetTableConfigForCmd (cmd )
5046 require .NotNil (t , cfg )
5147 require .NotNil (t , cfg .Search )
5248
@@ -63,26 +59,34 @@ func TestListPipelinesSearchEscapesLikeWildcards(t *testing.T) {
6359
6460func TestListPipelinesSearchDisabledWhenFilterSet (t * testing.T ) {
6561 cmd := newListPipelines ()
66- cmd .SetContext (t .Context ())
6762
6863 err := cmd .Flags ().Set ("filter" , "state = 'RUNNING'" )
6964 require .NoError (t , err )
7065
71- require .NoError (t , cmd .PreRunE (cmd , nil ))
72- cfg := tableview .GetTableConfig (cmd .Context ())
66+ cfg := tableview .GetTableConfigForCmd (cmd )
7367 require .NotNil (t , cfg )
68+ require .NotNil (t , cfg .Search )
69+
70+ // Simulate context setup so disableSearchIfFilterSet can read the config.
71+ cmd .SetContext (tableview .SetTableConfig (t .Context (), cfg ))
72+ disableSearchIfFilterSet (cmd )
7473
75- // The config stored in context should have Search disabled (shallow-copied,
76- // so the registered config itself is not mutated).
77- assert .Nil (t , cfg .Search )
74+ // The original config must not be mutated.
75+ assert .NotNil (t , cfg .Search , "original config must not be mutated" )
76+ // The config stored in context should have Search disabled.
77+ ctxCfg := tableview .GetTableConfig (cmd .Context ())
78+ require .NotNil (t , ctxCfg )
79+ assert .Nil (t , ctxCfg .Search )
7880}
7981
8082func TestListPipelinesSearchNotDisabledWithoutFilter (t * testing.T ) {
8183 cmd := newListPipelines ()
82- cmd .SetContext (t .Context ())
83- require .NoError (t , cmd .PreRunE (cmd , nil ))
8484
85- cfg := tableview .GetTableConfig (cmd . Context () )
85+ cfg := tableview .GetTableConfigForCmd (cmd )
8686 require .NotNil (t , cfg )
87+
88+ // Simulate context setup so disableSearchIfFilterSet can read the config.
89+ cmd .SetContext (tableview .SetTableConfig (t .Context (), cfg ))
90+ disableSearchIfFilterSet (cmd )
8791 assert .NotNil (t , cfg .Search )
8892}
0 commit comments