@@ -231,6 +231,93 @@ func TestDatahubGetInt(t *testing.T) {
231231 }
232232}
233233
234+ func TestGetStringMap (t * testing.T ) {
235+ t .Run ("valid map" , func (t * testing.T ) {
236+ cfg := map [string ]any {
237+ "descriptions" : map [string ]any {
238+ "datahub_search" : "Search the catalog" ,
239+ "datahub_get_entity" : "Get entity details" ,
240+ },
241+ }
242+ result := getStringMap (cfg , "descriptions" )
243+ if len (result ) != 2 {
244+ t .Fatalf ("expected 2 entries, got %d" , len (result ))
245+ }
246+ if result ["datahub_search" ] != "Search the catalog" {
247+ t .Errorf ("datahub_search = %q" , result ["datahub_search" ])
248+ }
249+ if result ["datahub_get_entity" ] != "Get entity details" {
250+ t .Errorf ("datahub_get_entity = %q" , result ["datahub_get_entity" ])
251+ }
252+ })
253+
254+ t .Run ("missing key" , func (t * testing.T ) {
255+ cfg := map [string ]any {}
256+ result := getStringMap (cfg , "descriptions" )
257+ if result != nil {
258+ t .Errorf ("expected nil for missing key, got %v" , result )
259+ }
260+ })
261+
262+ t .Run ("wrong type" , func (t * testing.T ) {
263+ cfg := map [string ]any {"descriptions" : "not a map" }
264+ result := getStringMap (cfg , "descriptions" )
265+ if result != nil {
266+ t .Errorf ("expected nil for wrong type, got %v" , result )
267+ }
268+ })
269+
270+ t .Run ("skips non-string values" , func (t * testing.T ) {
271+ cfg := map [string ]any {
272+ "descriptions" : map [string ]any {
273+ "valid" : "a string" ,
274+ "invalid" : dhCfgTestNumVal ,
275+ },
276+ }
277+ result := getStringMap (cfg , "descriptions" )
278+ if len (result ) != 1 {
279+ t .Fatalf ("expected 1 entry (non-string skipped), got %d" , len (result ))
280+ }
281+ if result ["valid" ] != "a string" {
282+ t .Errorf ("valid = %q" , result ["valid" ])
283+ }
284+ })
285+ }
286+
287+ func TestParseConfig_WithDescriptions (t * testing.T ) {
288+ cfg := map [string ]any {
289+ dhCfgTestURLKey : dhCfgTestExampleURL ,
290+ "descriptions" : map [string ]any {
291+ "datahub_search" : "Custom search description" ,
292+ },
293+ }
294+
295+ result , err := ParseConfig (cfg )
296+ if err != nil {
297+ t .Fatalf (dhCfgTestUnexpectedErr , err )
298+ }
299+ if len (result .Descriptions ) != 1 {
300+ t .Fatalf ("expected 1 description, got %d" , len (result .Descriptions ))
301+ }
302+ if result .Descriptions ["datahub_search" ] != "Custom search description" {
303+ t .Errorf ("datahub_search description = %q" , result .Descriptions ["datahub_search" ])
304+ }
305+ }
306+
307+ func TestParseConfig_NoDescriptions (t * testing.T ) {
308+ cfg := map [string ]any {
309+ dhCfgTestURLKey : dhCfgTestExampleURL ,
310+ }
311+
312+ result , err := ParseConfig (cfg )
313+ if err != nil {
314+ t .Fatalf (dhCfgTestUnexpectedErr , err )
315+ }
316+ if result .Descriptions != nil {
317+ t .Errorf ("expected nil descriptions, got %v" , result .Descriptions )
318+ }
319+ }
320+
234321func TestDatahubGetDuration (t * testing.T ) {
235322 cfg := map [string ]any {
236323 dhCfgTestString : "5m" ,
0 commit comments