fix: update Oracle tool arguments and improve test structure

This commit is contained in:
RUN
2026-01-30 17:41:37 +01:00
parent 8dc4bd7dd6
commit 251ef22839
2 changed files with 20 additions and 42 deletions

View File

@@ -91,7 +91,7 @@ curl -O https://storage.googleapis.com/genai-toolbox/v0.26.0/windows/amd64/toolb
"mcpServers": {
"oracle": {
"command": "./PATH/TO/toolbox",
"args": ["--prebuilt","oracle","--stdio"],
"args": ["--prebuilt","oracledb","--stdio"],
"env": {
"ORACLE_HOST": "",
"ORACLE_PORT": "1521",
@@ -121,7 +121,7 @@ curl -O https://storage.googleapis.com/genai-toolbox/v0.26.0/windows/amd64/toolb
"mcpServers": {
"oracle": {
"command": "./PATH/TO/toolbox",
"args": ["--prebuilt","oracle","--stdio"],
"args": ["--prebuilt","oracledb","--stdio"],
"env": {
"ORACLE_HOST": "",
"ORACLE_PORT": "1521",
@@ -154,7 +154,7 @@ curl -O https://storage.googleapis.com/genai-toolbox/v0.26.0/windows/amd64/toolb
"mcpServers": {
"oracle": {
"command": "./PATH/TO/toolbox",
"args": ["--prebuilt","oracle","--stdio"],
"args": ["--prebuilt","oracledb","--stdio"],
"env": {
"ORACLE_HOST": "",
"ORACLE_PORT": "1521",
@@ -185,7 +185,7 @@ curl -O https://storage.googleapis.com/genai-toolbox/v0.26.0/windows/amd64/toolb
"mcpServers": {
"oracle": {
"command": "./PATH/TO/toolbox",
"args": ["--prebuilt","oracle","--stdio"],
"args": ["--prebuilt","oracledb","--stdio"],
"env": {
"ORACLE_HOST": "",
"ORACLE_PORT": "1521",
@@ -246,7 +246,7 @@ curl -O https://storage.googleapis.com/genai-toolbox/v0.26.0/windows/amd64/toolb
"mcpServers": {
"oracle": {
"command": "./PATH/TO/toolbox",
"args": ["--prebuilt","oracle","--stdio"],
"args": ["--prebuilt","oracledb","--stdio"],
"env": {
"ORACLE_HOST": "",
"ORACLE_PORT": "1521",
@@ -275,7 +275,7 @@ curl -O https://storage.googleapis.com/genai-toolbox/v0.26.0/windows/amd64/toolb
"mcpServers": {
"oracle": {
"command": "./PATH/TO/toolbox",
"args": ["--prebuilt","oracle","--stdio"],
"args": ["--prebuilt","oracledb","--stdio"],
"env": {
"ORACLE_HOST": "",
"ORACLE_PORT": "1521",
@@ -302,7 +302,7 @@ curl -O https://storage.googleapis.com/genai-toolbox/v0.26.0/windows/amd64/toolb
"mcpServers": {
"oracle": {
"command": "./PATH/TO/toolbox",
"args": ["--prebuilt","oracle","--stdio"],
"args": ["--prebuilt","oracledb","--stdio"],
"env": {
"ORACLE_HOST": "",
"ORACLE_PORT": "1521",

View File

@@ -142,25 +142,15 @@ func initOracleConnection(ctx context.Context, user, pass, connStr string) (*sql
}
// TestOracleSimpleToolEndpoints tests Oracle SQL tool endpoints
func TestOracleTools(t *testing.T) {
func TestOracleSimpleToolEndpoints(t *testing.T) {
sourceConfig := getOracleVars(t)
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
defer cancel()
var args []string
ctx, err := testutils.ContextWithNewLogger()
if err != nil {
t.Fatalf("unexpected error: %s", err)
}
cfg := getOracleConfigFromEnv(t)
source, err := cfg.Initialize(ctx, nil)
if err != nil {
t.Fatalf("unable to initialize oracle source: %v", err)
}
db := source.(*oracle.Source).DB
db, err := initOracleConnection(ctx, OracleUser, OraclePass, OracleConnStr)
if err != nil {
t.Fatalf("unable to create Oracle connection pool: %s", err)
}
@@ -208,28 +198,16 @@ func TestOracleTools(t *testing.T) {
createTableStatement := `"CREATE TABLE t (id NUMBER GENERATED AS IDENTITY PRIMARY KEY, name VARCHAR2(255))"`
mcpSelect1Want := `{"jsonrpc":"2.0","id":"invoke my-auth-required-tool","result":{"content":[{"type":"text","text":"{\"1\":1}"}]}}`
t.Run("oracle-source-parsing", func(t *testing.T) {
// This test implicitly checks if the Oracle source configuration
// is parsed correctly by the toolbox server at startup.
// A failure in StartCmd or WaitForString would indicate a parsing issue.
if err != nil {
t.Errorf("Oracle source configuration failed to parse: %v", err)
} else {
fmt.Println("Oracle source configuration parsed successfully.")
}
})
t.Run("tool-endpoints", func(t *testing.T) {
tests.RunToolGetTest(t)
tests.RunToolInvokeTest(t, select1Want,
tests.DisableOptionalNullParamTest(),
tests.WithMyToolById4Want(`[{"id":4,"name":""}]`),
tests.DisableArrayTest(),
)
tests.RunMCPToolCallMethod(t, mcpMyFailToolWant, mcpSelect1Want)
tests.RunExecuteSqlToolInvokeTest(t, createTableStatement, select1Want)
tests.RunToolInvokeWithTemplateParameters(t, tableNameTemplateParam)
})
// Run tests
tests.RunToolGetTest(t)
tests.RunToolInvokeTest(t, select1Want,
tests.DisableOptionalNullParamTest(),
tests.WithMyToolById4Want("[{\"id\":4,\"name\":\"\"}]"),
tests.DisableArrayTest(),
)
tests.RunMCPToolCallMethod(t, mcpMyFailToolWant, mcpSelect1Want)
tests.RunExecuteSqlToolInvokeTest(t, createTableStatement, select1Want)
tests.RunToolInvokeWithTemplateParameters(t, tableNameTemplateParam)
}