(t *testing.T)
| 7 | ) |
| 8 | |
| 9 | func TestCaseWithVal(t *testing.T) { |
| 10 | caseStmt := Case("number"). |
| 11 | When("1", "one"). |
| 12 | When("2", "two"). |
| 13 | Else(Expr("?", "big number")) |
| 14 | |
| 15 | qb := Select(). |
| 16 | Column(caseStmt). |
| 17 | From("table") |
| 18 | sql, args, err := qb.ToSql() |
| 19 | |
| 20 | assert.NoError(t, err) |
| 21 | |
| 22 | expectedSql := "SELECT CASE number " + |
| 23 | "WHEN 1 THEN one " + |
| 24 | "WHEN 2 THEN two " + |
| 25 | "ELSE ? " + |
| 26 | "END " + |
| 27 | "FROM table" |
| 28 | assert.Equal(t, expectedSql, sql) |
| 29 | |
| 30 | expectedArgs := []interface{}{"big number"} |
| 31 | assert.Equal(t, expectedArgs, args) |
| 32 | } |
| 33 | |
| 34 | func TestCaseWithComplexVal(t *testing.T) { |
| 35 | caseStmt := Case("? > ?", 10, 5). |
nothing calls this directly
no test coverage detected
searching dependent graphs…