Files
db/exp/window_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

85 lines
2.4 KiB
Go

package exp_test
import (
"testing"
"git.fsdpf.net/go/db/exp"
"github.com/stretchr/testify/suite"
)
type windowExpressionTest struct {
suite.Suite
}
func TestWindowExpressionSuite(t *testing.T) {
suite.Run(t, new(windowExpressionTest))
}
func (wet *windowExpressionTest) TestClone() {
w := exp.NewWindowExpression(exp.NewIdentifierExpression("", "", "w"), nil, nil, nil)
w2 := w.Clone()
wet.Equal(w, w2)
}
func (wet *windowExpressionTest) TestExpression() {
w := exp.NewWindowExpression(exp.NewIdentifierExpression("", "", "w"), nil, nil, nil)
w2 := w.Expression()
wet.Equal(w, w2)
}
func (wet *windowExpressionTest) TestName() {
name := exp.NewIdentifierExpression("", "", "w")
w := exp.NewWindowExpression(exp.NewIdentifierExpression("", "", "w"), nil, nil, nil)
wet.Equal(name, w.Name())
}
func (wet *windowExpressionTest) TestPartitionCols() {
cols := exp.NewColumnListExpression("a", "b")
w := exp.NewWindowExpression(exp.NewIdentifierExpression("", "", "w"), nil, cols, nil)
wet.Equal(cols, w.PartitionCols())
wet.Equal(cols, w.Clone().(exp.WindowExpression).PartitionCols())
}
func (wet *windowExpressionTest) TestOrderCols() {
cols := exp.NewColumnListExpression("a", "b")
w := exp.NewWindowExpression(exp.NewIdentifierExpression("", "", "w"), nil, nil, cols)
wet.Equal(cols, w.OrderCols())
wet.Equal(cols, w.Clone().(exp.WindowExpression).OrderCols())
}
func (wet *windowExpressionTest) TestPartitionBy() {
cols := exp.NewColumnListExpression("a", "b")
w := exp.NewWindowExpression(exp.NewIdentifierExpression("", "", "w"), nil, nil, nil).PartitionBy("a", "b")
wet.Equal(cols, w.PartitionCols())
}
func (wet *windowExpressionTest) TestOrderBy() {
cols := exp.NewColumnListExpression("a", "b")
w := exp.NewWindowExpression(exp.NewIdentifierExpression("", "", "w"), nil, nil, nil).OrderBy("a", "b")
wet.Equal(cols, w.OrderCols())
}
func (wet *windowExpressionTest) TestParent() {
parent := exp.NewIdentifierExpression("", "", "w1")
w := exp.NewWindowExpression(exp.NewIdentifierExpression("", "", "w"), parent, nil, nil)
wet.Equal(parent, w.Parent())
}
func (wet *windowExpressionTest) TestInherit() {
parent := exp.NewIdentifierExpression("", "", "w1")
w := exp.NewWindowExpression(exp.NewIdentifierExpression("", "", "w"), parent, nil, nil)
wet.Equal(parent, w.Parent())
w = w.Inherit("w2")
wet.Equal(exp.NewIdentifierExpression("", "", "w2"), w.Parent())
}