Skip to content

Commit 7011296

Browse files
committed
test: Fix nil issue
1 parent 3a4c79b commit 7011296

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

tests/mcp_tool.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ func RunMCPPostgresListSchemasTest(t *testing.T, ctx context.Context, pool *pgxp
537537
name: "invoke list_schemas with non-existent schema",
538538
args: map[string]any{"schema_name": "non_existent_schema"},
539539
wantStatusCode: http.StatusOK,
540-
want: nil,
540+
want: []map[string]any{},
541541
},
542542
}
543543
for _, tc := range invokeTcs {
@@ -555,7 +555,7 @@ func RunMCPPostgresListSchemasTest(t *testing.T, ctx context.Context, pool *pgxp
555555
if mcpResp.Result.IsError {
556556
t.Fatalf("list_schemas returned error result: %v", mcpResp.Result)
557557
}
558-
var gotObj []map[string]any
558+
gotObj := []map[string]any{}
559559
got := getMCPResultText(mcpResp)
560560
if got != "null" {
561561
gotObj, err = unmarshalMCPResult[map[string]any](got)
@@ -844,7 +844,7 @@ func RunMCPPostgresListTriggersTest(t *testing.T, ctx context.Context, pool *pgx
844844
name: "filter by non-existent trigger_name",
845845
args: map[string]any{"trigger_name": "non_existent_trigger"},
846846
wantStatusCode: http.StatusOK,
847-
want: nil,
847+
want: []map[string]any{},
848848
},
849849
}
850850
for _, tc := range invokeTcs {
@@ -950,7 +950,7 @@ func RunMCPPostgresListSequencesTest(t *testing.T, ctx context.Context, pool *pg
950950
name: "invoke list_sequences with non-existent sequence",
951951
args: map[string]any{"sequence_name": "non_existent_sequence"},
952952
wantStatusCode: http.StatusOK,
953-
want: nil,
953+
want: []map[string]any{},
954954
},
955955
}
956956
for _, tc := range invokeTcs {
@@ -968,7 +968,7 @@ func RunMCPPostgresListSequencesTest(t *testing.T, ctx context.Context, pool *pg
968968
if mcpResp.Result.IsError {
969969
t.Fatalf("list_sequences returned error result: %v", mcpResp.Result)
970970
}
971-
var gotObj []map[string]any
971+
gotObj := []map[string]any{}
972972
got := getMCPResultText(mcpResp)
973973
if got != "null" {
974974
gotObj, err = unmarshalMCPResult[map[string]any](got)
@@ -1086,7 +1086,7 @@ func RunMCPPostgresListIndexesTest(t *testing.T, ctx context.Context, pool *pgxp
10861086
name: "invoke list_indexes with non-existent table",
10871087
args: map[string]any{"table_name": "non_existent_table"},
10881088
wantStatusCode: http.StatusOK,
1089-
want: nil,
1089+
want: []map[string]any{},
10901090
},
10911091
}
10921092
for _, tc := range invokeTcs {
@@ -1105,7 +1105,7 @@ func RunMCPPostgresListIndexesTest(t *testing.T, ctx context.Context, pool *pgxp
11051105
if mcpResp.Result.IsError {
11061106
t.Fatalf("list_indexes returned error result: %v", mcpResp.Result)
11071107
}
1108-
var gotObj []map[string]any
1108+
gotObj := []map[string]any{}
11091109
for _, content := range mcpResp.Result.Content {
11101110
got := content.Text
11111111
t.Logf("list_indexes got: %s", got)

0 commit comments

Comments
 (0)