(t *testing.T)
| 75 | } |
| 76 | |
| 77 | func TestCaseWithExpr(t *testing.T) { |
| 78 | caseStmt := Case(Expr("x = ?", true)). |
| 79 | When("true", Expr("?", "it's true!")). |
| 80 | Else("42") |
| 81 | |
| 82 | qb := Select().Column(caseStmt).From("table") |
| 83 | sql, args, err := qb.ToSql() |
| 84 | |
| 85 | assert.NoError(t, err) |
| 86 | |
| 87 | expectedSql := "SELECT CASE x = ? " + |
| 88 | "WHEN true THEN ? " + |
| 89 | "ELSE 42 " + |
| 90 | "END " + |
| 91 | "FROM table" |
| 92 | |
| 93 | assert.Equal(t, expectedSql, sql) |
| 94 | |
| 95 | expectedArgs := []interface{}{true, "it's true!"} |
| 96 | assert.Equal(t, expectedArgs, args) |
| 97 | } |
| 98 | |
| 99 | func TestMultipleCase(t *testing.T) { |
| 100 | caseStmtNoval := Case(Expr("x = ?", true)). |
nothing calls this directly
no test coverage detected
searching dependent graphs…