Files
tasks/tools/sql/clitest/setup_task_tests.go
zeekay 5a601d081b rebrand: go.temporal.io/server -> github.com/hanzoai/tasks
Full module path rebrand from Temporal to Hanzo Tasks:
- go.mod module: github.com/hanzoai/tasks
- All internal Go imports updated (1906 files)
- cmd/server renamed to cmd/tasksd
- Binary name: tasksd (was temporal-server)
- Docker images: hanzoai/tasks (was temporalio/server)
- README rewritten with Hanzo Tasks branding
- LLM.md created with integration notes
- Makefile, goreleaser, CI workflows updated
- go.temporal.io/sdk and go.temporal.io/api imports preserved (separate repos)

Fork of Temporal.io (MIT license).
2026-03-19 10:36:40 -07:00

117 lines
2.5 KiB
Go

package clitest
import (
"github.com/hanzoai/tasks/common/shuffle"
"github.com/hanzoai/tasks/tools/common/schema/test"
"github.com/hanzoai/tasks/tools/sql"
)
type (
// SetupSchemaTestSuite defines a test suite
SetupSchemaTestSuite struct {
test.SetupSchemaTestBase
host string
port string
pluginName string
sqlQuery string
conn *sql.Connection
}
)
const (
testCLIDatabasePrefix = "test_"
testCLIDatabaseSuffix = "cli_database"
)
// NewSetupSchemaTestSuite returns a test suite
func NewSetupSchemaTestSuite(
host string,
port string,
pluginName string,
sqlQuery string,
) *SetupSchemaTestSuite {
return &SetupSchemaTestSuite{
host: host,
port: port,
pluginName: pluginName,
sqlQuery: sqlQuery,
}
}
// SetupSuite setup test suite
func (s *SetupSchemaTestSuite) SetupSuite() {
conn, err := newTestConn("", s.host, s.port, s.pluginName)
if err != nil {
s.Fail("error creating sql connection:%v", err)
}
s.conn = conn
s.SetupSuiteBase(conn, s.pluginName, test.ConnectParams{
Host: s.host,
Port: s.port,
User: testUser,
Password: testPassword,
})
}
// TearDownSuite tear down test suite
func (s *SetupSchemaTestSuite) TearDownSuite() {
s.TearDownSuiteBase()
}
// TestCreateDatabase test
func (s *SetupSchemaTestSuite) TestCreateDatabase() {
testDatabase := testCLIDatabasePrefix + shuffle.String(testCLIDatabaseSuffix)
err := sql.RunTool([]string{
"./tool",
"--ep", s.host,
"--p", s.port,
"-u", testUser,
"--pw", testPassword,
"--pl", s.pluginName,
"--db", testDatabase,
"create",
})
s.NoError(err)
err = s.conn.DropDatabase(testDatabase)
s.NoError(err)
}
func (s *SetupSchemaTestSuite) TestCreateDatabaseIdempotent() {
testDatabase := testCLIDatabasePrefix + shuffle.String(testCLIDatabaseSuffix)
err := sql.RunTool([]string{
"./tool",
"--ep", s.host,
"--p", s.port,
"-u", testUser,
"--pw", testPassword,
"--pl", s.pluginName,
"--db", testDatabase,
"create",
})
s.NoError(err)
err = sql.RunTool([]string{
"./tool",
"--ep", s.host,
"--p", s.port,
"-u", testUser,
"--pw", testPassword,
"--pl", s.pluginName,
"--db", testDatabase,
"create",
})
s.NoError(err)
err = s.conn.DropDatabase(testDatabase)
s.NoError(err)
}
// TestSetupSchema test
func (s *SetupSchemaTestSuite) TestSetupSchema() {
conn, err := newTestConn(s.DBName, s.host, s.port, s.pluginName)
s.NoError(err)
defer conn.Close()
s.RunSetupTest(sql.BuildCLIOptions(), conn, "--db", s.sqlQuery, []string{"executions", "current_executions"})
}