@@ -52,10 +52,11 @@ func TestReadConfigValid(t *testing.T) {
5252	validConfigPath  :=  writeConfig (t , ` 
5353log_level = 1 
5454port = "9999" 
55- kubeconfig = "test" 
55+ sse_base_url = "https://example.com" 
56+ kubeconfig = "./path/to/config" 
5657list_output = "yaml" 
5758read_only = true 
58- disable_destructive = false  
59+ disable_destructive = true  
5960
6061denied_resources = [ 
6162    {group = "apps", version = "v1", kind = "Deployment"}, 
@@ -84,33 +85,62 @@ disabled_tools = ["pods_delete", "pods_top", "pods_log", "pods_run", "pods_exec"
8485			config .DeniedResources [0 ].Kind  !=  "Deployment"  {
8586			t .Errorf ("Unexpected denied resources: %v" , config .DeniedResources [0 ])
8687		}
88+ 	})
89+ 	t .Run ("log_level parsed correctly" , func (t  * testing.T ) {
8790		if  config .LogLevel  !=  1  {
8891			t .Fatalf ("Unexpected log level: %v" , config .LogLevel )
8992		}
93+ 	})
94+ 	t .Run ("port parsed correctly" , func (t  * testing.T ) {
9095		if  config .Port  !=  "9999"  {
9196			t .Fatalf ("Unexpected port value: %v" , config .Port )
9297		}
93- 		if  config .SSEBaseURL  !=  ""  {
98+ 	})
99+ 	t .Run ("sse_base_url parsed correctly" , func (t  * testing.T ) {
100+ 		if  config .SSEBaseURL  !=  "https://example.com"  {
94101			t .Fatalf ("Unexpected sse_base_url value: %v" , config .SSEBaseURL )
95102		}
96- 		if  config .KubeConfig  !=  "test"  {
103+ 	})
104+ 	t .Run ("kubeconfig parsed correctly" , func (t  * testing.T ) {
105+ 		if  config .KubeConfig  !=  "./path/to/config"  {
97106			t .Fatalf ("Unexpected kubeconfig value: %v" , config .KubeConfig )
98107		}
108+ 	})
109+ 	t .Run ("list_output parsed correctly" , func (t  * testing.T ) {
99110		if  config .ListOutput  !=  "yaml"  {
100111			t .Fatalf ("Unexpected list_output value: %v" , config .ListOutput )
101112		}
113+ 	})
114+ 	t .Run ("read_only parsed correctly" , func (t  * testing.T ) {
102115		if  ! config .ReadOnly  {
103116			t .Fatalf ("Unexpected read-only mode: %v" , config .ReadOnly )
104117		}
105- 		if  config .DisableDestructive  {
118+ 	})
119+ 	t .Run ("disable_destructive parsed correctly" , func (t  * testing.T ) {
120+ 		if  ! config .DisableDestructive  {
106121			t .Fatalf ("Unexpected disable destructive: %v" , config .DisableDestructive )
107122		}
123+ 	})
124+ 	t .Run ("enabled_tools parsed correctly" , func (t  * testing.T ) {
108125		if  len (config .EnabledTools ) !=  8  {
109126			t .Fatalf ("Unexpected enabled tools: %v" , config .EnabledTools )
127+ 
110128		}
129+ 		for  i , tool  :=  range  []string {"configuration_view" , "events_list" , "namespaces_list" , "pods_list" , "resources_list" , "resources_get" , "resources_create_or_update" , "resources_delete" } {
130+ 			if  config .EnabledTools [i ] !=  tool  {
131+ 				t .Errorf ("Expected enabled tool %d to be %s, got %s" , i , tool , config .EnabledTools [i ])
132+ 			}
133+ 		}
134+ 	})
135+ 	t .Run ("disabled_tools parsed correctly" , func (t  * testing.T ) {
111136		if  len (config .DisabledTools ) !=  5  {
112137			t .Fatalf ("Unexpected disabled tools: %v" , config .DisabledTools )
113138		}
139+ 		for  i , tool  :=  range  []string {"pods_delete" , "pods_top" , "pods_log" , "pods_run" , "pods_exec" } {
140+ 			if  config .DisabledTools [i ] !=  tool  {
141+ 				t .Errorf ("Expected disabled tool %d to be %s, got %s" , i , tool , config .DisabledTools [i ])
142+ 			}
143+ 		}
114144	})
115145}
116146
0 commit comments