tests

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: May 28, 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 SERVICE_ACCOUNT_EMAIL = os.Getenv("SERVICE_ACCOUNT_EMAIL")

Functions

func AddMssqlExecuteSqlConfig added in v0.6.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 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 GetHTTPToolsConfig

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

GetHTTPToolsConfig returns a mock HTTP tool's config file

func GetMssqlLAuthToolInfo

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

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

func GetMssqlParamToolInfo

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

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

func GetMssqlWants

func GetMssqlWants() (string, string, string)

GetMssqlWants return the expected wants for mssql

func GetMysqlLAuthToolInfo

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

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

func GetMysqlParamToolInfo

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

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

func GetMysqlWants

func GetMysqlWants() (string, string, string)

GetMysqlWants return the expected wants for mysql

func GetNonSpannerInvokeParamWant

func GetNonSpannerInvokeParamWant() (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, []any)

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

func GetPostgresWants

func GetPostgresWants() (string, string, string)

GetPostgresWants return the expected wants for postgres

func GetToolsConfig

func GetToolsConfig(sourceConfig map[string]any, toolKind, param_tool_statement, auth_tool_statement 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, select_1_want string)

func RunMCPToolCallMethod

func RunMCPToolCallMethod(t *testing.T, invoke_param_want, fail_invocation_want 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 RunToolInvokeTest

func RunToolInvokeTest(t *testing.T, select_1_want, invoke_param_want string)

RunToolInvoke runs the tool invoke endpoint

func SetupMsSQLTable

func SetupMsSQLTable(t *testing.T, ctx context.Context, pool *sql.DB, create_statement, insert_statement, 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, create_statement, insert_statement, tableName string, params []any) func(*testing.T)

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

func SetupPostgresSQLTable

func SetupPostgresSQLTable(t *testing.T, ctx context.Context, pool *pgxpool.Pool, create_statement, insert_statement, 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.

func (*CmdExec) WaitForString

func (c *CmdExec) WaitForString(ctx context.Context, re *regexp.Regexp) (string, error)

WaitForString waits until the server logs a single line that matches the provided regex. returns the output of whatever the server sent so far.

Jump to

Keyboard shortcuts

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