Files
db/exp/truncate_clauses_test.go
whatandClaude 304d553b3c docs: Add CLAUDE.md with codebase guidance
Create comprehensive documentation for future Claude Code instances working in this repository, including:
- Development commands for testing, building, and code quality
- Core architecture overview of the SQL query builder system
- Directory structure and component explanations
- Testing patterns and conventions
- Key dependencies and their purposes

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-27 15:47:28 +08:00

69 lines
1.5 KiB
Go

package exp_test
import (
"testing"
"git.fsdpf.net/go/db/exp"
"github.com/stretchr/testify/suite"
)
type truncateClausesSuite struct {
suite.Suite
}
func TestTruncateClausesSuite(t *testing.T) {
suite.Run(t, new(truncateClausesSuite))
}
func (tcs *truncateClausesSuite) TestHasTable() {
c := exp.NewTruncateClauses()
cle := exp.NewColumnListExpression("test1", "test2")
c2 := c.SetTable(cle)
tcs.False(c.HasTable())
tcs.True(c2.HasTable())
}
func (tcs *truncateClausesSuite) TestTable() {
c := exp.NewTruncateClauses()
cle := exp.NewColumnListExpression("test1", "test2")
c2 := c.SetTable(cle)
tcs.Nil(c.Table())
tcs.Equal(cle, c2.Table())
}
func (tcs *truncateClausesSuite) TestSetTable() {
cle := exp.NewColumnListExpression("test1", "test2")
c := exp.NewTruncateClauses().SetTable(cle)
cle2 := exp.NewColumnListExpression("test3", "test4")
c2 := c.SetTable(cle2)
tcs.Equal(cle, c.Table())
tcs.Equal(cle2, c2.Table())
}
func (tcs *truncateClausesSuite) TestOptions() {
c := exp.NewTruncateClauses()
opts := exp.TruncateOptions{Restrict: true, Identity: "RESTART", Cascade: true}
c2 := c.SetOptions(opts)
tcs.Equal(exp.TruncateOptions{}, c.Options())
tcs.Equal(opts, c2.Options())
}
func (tcs *truncateClausesSuite) TestSetOptions() {
opts := exp.TruncateOptions{Restrict: true, Identity: "RESTART", Cascade: true}
c := exp.NewTruncateClauses().SetOptions(opts)
opts2 := exp.TruncateOptions{Restrict: false, Identity: "RESTART", Cascade: false}
c2 := c.SetOptions(opts2)
tcs.Equal(opts, c.Options())
tcs.Equal(opts2, c2.Options())
}