feat(format): case_collapse uses line_width via Doc-IR
This commit is contained in:
@@ -632,3 +632,18 @@ func TestWhereWhenLong(t *testing.T) {
|
||||
t.Errorf("broken when_long should equal always:\n%s\n---\n%s", long, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDMLCaseCollapseUsesLineWidth(t *testing.T) {
|
||||
st := config.Default()
|
||||
st.CaseWhenWrap = true
|
||||
st.CaseCollapse = true
|
||||
src := "select case when a = 1 then 'one' when a = 2 then 'two' else 'other' end from t;"
|
||||
st.LineWidth = 120
|
||||
if got := File(parser.Parse(src), st); strings.Contains(got, "\n WHEN") {
|
||||
t.Errorf("fits in 120, should collapse:\n%s", got)
|
||||
}
|
||||
st.LineWidth = 30
|
||||
if got := File(parser.Parse(src), st); !strings.Contains(got, "\n WHEN") {
|
||||
t.Errorf("exceeds 30, should wrap:\n%s", got)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user