replace badrequests

This commit is contained in:
duwenxin
2026-02-09 19:16:00 -05:00
parent f3ed08bec5
commit 95b15e4db7
11 changed files with 74 additions and 88 deletions

View File

@@ -169,11 +169,10 @@ func TestCloneInstanceToolEndpoints(t *testing.T) {
want: `{"name":"op2","status":"PENDING"}`,
},
{
name: "missing destination instance name",
toolName: "clone-instance",
body: `{"project": "p1", "sourceInstanceName": "source-instance"}`,
expectError: true,
errorStatus: http.StatusBadRequest,
name: "missing destination instance name",
toolName: "clone-instance",
body: `{"project": "p1", "sourceInstanceName": "source-instance"}`,
want: `{"error":"parameter \"destinationInstanceName\" is required"}`,
},
}

View File

@@ -158,11 +158,10 @@ func TestCreateBackupToolEndpoints(t *testing.T) {
want: `{"name":"op1","status":"PENDING"}`,
},
{
name: "missing instance name",
toolName: "create-backup",
body: `{"project": "p1", "escription": "invalid"}`,
expectError: true,
errorStatus: http.StatusBadRequest,
name: "missing instance name",
toolName: "create-backup",
body: `{"project": "p1", "escription": "invalid"}`,
want: `{"error":"parameter \"instance\" is required"}`,
},
}

View File

@@ -155,11 +155,10 @@ func TestCreateDatabaseToolEndpoints(t *testing.T) {
want: `{"name":"op1","status":"PENDING"}`,
},
{
name: "missing name",
toolName: "create-database",
body: `{"project": "p1", "instance": "i1"}`,
expectError: true,
errorStatus: http.StatusBadRequest,
name: "missing name",
toolName: "create-database",
body: `{"project": "p1", "instance": "i1"}`,
want: `{"error":"parameter \"name\" is required"}`,
},
}

View File

@@ -138,11 +138,10 @@ func TestListDatabasesToolEndpoints(t *testing.T) {
want: `[{"name":"db1","charset":"utf8","collation":"utf8_general_ci"},{"name":"db2","charset":"utf8mb4","collation":"utf8mb4_unicode_ci"}]`,
},
{
name: "missing instance",
toolName: "list-databases",
body: `{"project": "p1"}`,
expectError: true,
errorStatus: http.StatusBadRequest,
name: "missing instance",
toolName: "list-databases",
body: `{"project": "p1"}`,
want: `{"error":"parameter \"instance\" is required"}`,
},
}

View File

@@ -188,18 +188,16 @@ func TestRestoreBackupToolEndpoints(t *testing.T) {
want: `{"error":"error processing GCP request: source project and instance are required when restoring via backup ID"}`,
},
{
name: "missing backup identifier",
toolName: "restore-backup",
body: `{"target_project": "p1", "target_instance": "instance-project-level"}`,
expectError: true,
errorStatus: http.StatusBadRequest,
name: "missing backup identifier",
toolName: "restore-backup",
body: `{"target_project": "p1", "target_instance": "instance-project-level"}`,
want: `{"error":"source project and instance are required when restoring via backup ID"}`,
},
{
name: "missing target instance info",
toolName: "restore-backup",
body: `{"backup_id": "12345"}`,
expectError: true,
errorStatus: http.StatusBadRequest,
name: "missing target instance info",
toolName: "restore-backup",
body: `{"backup_id": "12345"}`,
want: `{"error":"parameter \"target_instance\" is required"}`,
},
}