tests

package
v0.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 25, 2025 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ClientId = os.Getenv("CLIENT_ID")
View Source
var ServiceAccountEmail = os.Getenv("SERVICE_ACCOUNT_EMAIL")

Functions

func AddMSSQLExecuteSqlConfig added in v0.9.0

func AddMSSQLExecuteSqlConfig(t *testing.T, config map[string]any) map[string]any

AddMSSQLExecuteSqlConfig gets the tools config for `mssql-execute-sql`

func AddMySqlExecuteSqlConfig added in v0.6.0

func AddMySqlExecuteSqlConfig(t *testing.T, config map[string]any) map[string]any

AddMySqlExecuteSqlConfig gets the tools config for `mysql-execute-sql`

func AddPgExecuteSqlConfig

func AddPgExecuteSqlConfig(t *testing.T, config map[string]any) map[string]any

AddPgExecuteSqlConfig gets the tools config for `postgres-execute-sql`

func AddTemplateParamConfig added in v0.7.0

func AddTemplateParamConfig(t *testing.T, config map[string]any, toolKind, tmplSelectCombined, tmplSelectFilterCombined string, tmplSelectAll string) map[string]any

func GetCloudSQLDialOpts

func GetCloudSQLDialOpts(ipType string) ([]cloudsqlconn.DialOption, error)

GetCloudSQLDialOpts returns cloud sql connector's dial option for ip type.

func GetGoogleIdToken

func GetGoogleIdToken(audience string) (string, error)

GetGoogleIdToken retrieve and return the Google ID token

func GetMSSQLAuthToolInfo added in v0.9.0

func GetMSSQLAuthToolInfo(tableName string) (string, string, string, []any)

GetMSSQLAuthToolInfo returns statements and param of my-auth-tool for mssql-sql kind

func GetMSSQLParamToolInfo added in v0.9.0

func GetMSSQLParamToolInfo(tableName string) (string, string, string, string, string, string, []any)

GetMSSQLParamToolInfo returns statements and param for my-tool mssql-sql kind

func GetMSSQLTmplToolStatement added in v0.9.0

func GetMSSQLTmplToolStatement() (string, string)

GetMSSQLTmplToolStatement returns statements and param for template parameter test cases for mysql-sql kind

func GetMSSQLWants added in v0.9.0

func GetMSSQLWants() (string, string, string)

GetMSSQLWants return the expected wants for mssql

func GetMySQLAuthToolInfo added in v0.9.0

func GetMySQLAuthToolInfo(tableName string) (string, string, string, []any)

GetMySQLAuthToolInfo returns statements and param of my-auth-tool for mysql-sql kind

func GetMySQLParamToolInfo added in v0.9.0

func GetMySQLParamToolInfo(tableName string) (string, string, string, string, string, string, []any)

GetMySQLParamToolInfo returns statements and param for my-tool mysql-sql kind

func GetMySQLTmplToolStatement added in v0.9.0

func GetMySQLTmplToolStatement() (string, string)

GetMySQLTmplToolStatement returns statements and param for template parameter test cases for mysql-sql kind

func GetMySQLWants added in v0.9.0

func GetMySQLWants() (string, string, string)

GetMySQLWants return the expected wants for mysql

func GetNonSpannerInvokeParamWant

func GetNonSpannerInvokeParamWant() (string, string, string, string)

func GetPostgresSQLAuthToolInfo

func GetPostgresSQLAuthToolInfo(tableName string) (string, string, string, []any)

GetPostgresSQLAuthToolInfo returns statements and param of my-auth-tool for postgres-sql kind

func GetPostgresSQLParamToolInfo

func GetPostgresSQLParamToolInfo(tableName string) (string, string, string, string, string, string, []any)

GetPostgresSQLParamToolInfo returns statements and param for my-tool postgres-sql kind

func GetPostgresSQLTmplToolStatement added in v0.7.0

func GetPostgresSQLTmplToolStatement() (string, string)

GetPostgresSQLTmplToolStatement returns statements and param for template parameter test cases for postgres-sql kind

func GetPostgresWants

func GetPostgresWants() (string, string, string)

GetPostgresWants return the expected wants for postgres

func GetRedisValkeyToolsConfig added in v0.8.0

func GetRedisValkeyToolsConfig(sourceConfig map[string]any, toolKind string) map[string]any

func GetRedisValkeyWants added in v0.8.0

func GetRedisValkeyWants() (string, string, string, string, string, string)

GetRedisWants return the expected wants for redis

func GetToolsConfig

func GetToolsConfig(sourceConfig map[string]any, toolKind, paramToolStatement, idParamToolStmt, nameParamToolStmt, arrayToolStatement, authToolStatement string) map[string]any

GetToolsConfig returns a mock tools config file

func RunExecuteSqlToolInvokeTest added in v0.6.0

func RunExecuteSqlToolInvokeTest(t *testing.T, createTableStatement string, select1Want string)

func RunInitialize added in v0.8.0

func RunInitialize(t *testing.T, protocolVersion string) string

RunInitialize runs the initialize lifecycle for mcp to set up client-server connection

func RunMCPToolCallMethod

func RunMCPToolCallMethod(t *testing.T, invokeParamWant, failInvocationWant string)

RunMCPToolCallMethod runs the tool/call for mcp endpoint

func RunSourceConnectionTest

func RunSourceConnectionTest(t *testing.T, sourceConfig map[string]any, toolKind string) error

RunSourceConnection test for source connection

func RunToolGetTest

func RunToolGetTest(t *testing.T)

RunToolGet runs the tool get endpoint

func RunToolGetTestByName added in v0.10.0

func RunToolGetTestByName(t *testing.T, name string, want map[string]any)

func RunToolInvokeParametersTest added in v0.10.0

func RunToolInvokeParametersTest(t *testing.T, name string, params []byte, simpleWant string)

func RunToolInvokeSimpleTest added in v0.10.0

func RunToolInvokeSimpleTest(t *testing.T, name string, simpleWant string)

RunToolInvokeSimpleTest runs the tool invoke endpoint with no parameters

func RunToolInvokeTest

func RunToolInvokeTest(t *testing.T, select1Want, invokeParamWant, invokeIdNullWant, nullString string, supportNullParam, supportsArray bool)

RunToolInvoke runs the tool invoke endpoint

func RunToolInvokeWithTemplateParameters added in v0.7.0

func RunToolInvokeWithTemplateParameters(t *testing.T, tableName string, config *TemplateParameterTestConfig)

RunToolInvokeWithTemplateParameters runs tool invoke test cases with template parameters.

func SetupMsSQLTable

func SetupMsSQLTable(t *testing.T, ctx context.Context, pool *sql.DB, createStatement, insertStatement, tableName string, params []any) func(*testing.T)

SetupMsSQLTable creates and inserts data into a table of tool compatible with mssql-sql tool

func SetupMySQLTable

func SetupMySQLTable(t *testing.T, ctx context.Context, pool *sql.DB, createStatement, insertStatement, tableName string, params []any) func(*testing.T)

SetupMySQLTable creates and inserts data into a table of tool compatible with mysql-sql tool

func SetupPostgresSQLTable

func SetupPostgresSQLTable(t *testing.T, ctx context.Context, pool *pgxpool.Pool, createStatement, insertStatement, tableName string, params []any) func(*testing.T)

SetupPostgresSQLTable creates and inserts data into a table of tool compatible with postgres-sql tool

Types

type CmdExec

type CmdExec struct {
	Out io.ReadCloser
	// contains filtered or unexported fields
}

CmdExec represents an invocation of a toolbox command.

func StartCmd

func StartCmd(ctx context.Context, toolsFile map[string]any, args ...string) (*CmdExec, func(), error)

StartCmd returns a CmdExec representing a running instance of a toolbox command.

func (*CmdExec) Close

func (c *CmdExec) Close()

Close releases any resources associated with the instance.

func (*CmdExec) Done

func (c *CmdExec) Done() bool

Done returns true if the command has exited.

func (*CmdExec) Stop

func (c *CmdExec) Stop()

Stop sends the TERM signal to the cmd and returns.

func (*CmdExec) Wait

func (c *CmdExec) Wait(ctx context.Context) error

Waits until the execution is completed and returns any error from the result.

type Option added in v0.8.0

type Option func(*TemplateParameterTestConfig)

func WithCreateColArray added in v0.8.0

func WithCreateColArray(s string) Option

WithCreateColArray is the option function to configure replaceNameColFilter.

func WithIgnoreDdl added in v0.8.0

func WithIgnoreDdl() Option

WithIgnoreDdl is the option function to configure ignoreDdl.

func WithIgnoreInsert added in v0.8.0

func WithIgnoreInsert() Option

WithIgnoreInsert is the option function to configure ignoreInsert.

func WithReplaceNameColFilter added in v0.8.0

func WithReplaceNameColFilter(s string) Option

WithReplaceNameColFilter is the option function to configure replaceNameColFilter.

func WithReplaceNameFieldArray added in v0.8.0

func WithReplaceNameFieldArray(s string) Option

WithReplaceNameFieldArray is the option function to configure replaceNameFieldArray.

func WithSelect1Want added in v0.8.0

func WithSelect1Want(s string) Option

WithSelect1Want is the option function to configure select1Want.

func WithSelectAllWant added in v0.8.0

func WithSelectAllWant(s string) Option

WithSelectAllWant is the option function to configure selectAllWant.

type TemplateParameterTestConfig added in v0.8.0

type TemplateParameterTestConfig struct {
	// contains filtered or unexported fields
}

TemplateParameterTestConfig represents the various configuration options for template parameter tests.

func NewTemplateParameterTestConfig added in v0.8.0

func NewTemplateParameterTestConfig(options ...Option) *TemplateParameterTestConfig

NewTemplateParameterTestConfig creates a new TemplateParameterTestConfig instances with options.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL