(t *testing.T)
| 118 | } |
| 119 | |
| 120 | func TestPlugin_OnParseError(t *testing.T) { |
| 121 | var called bool |
| 122 | var errSQL string |
| 123 | |
| 124 | plugin := gosqlxgorm.NewPluginWithOptions(gosqlxgorm.PluginOptions{ |
| 125 | OnParseError: func(sql string, err error) { |
| 126 | called = true |
| 127 | errSQL = sql |
| 128 | }, |
| 129 | }) |
| 130 | |
| 131 | db := openTestDB(t) |
| 132 | _ = db.Use(plugin) |
| 133 | |
| 134 | // Execute a raw query that is very likely to trigger a parse error. |
| 135 | db.Exec("PRAGMA table_info('users')") |
| 136 | |
| 137 | // If no parse error was triggered, the test is inconclusive but should not fail. |
| 138 | // We check that the callback was wired correctly by verifying the stats. |
| 139 | stats := plugin.Stats() |
| 140 | if stats.ParseErrors > 0 && !called { |
| 141 | t.Error("OnParseError callback was not called despite parse errors") |
| 142 | } |
| 143 | if called && errSQL == "" { |
| 144 | t.Error("OnParseError was called but sql was empty") |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | func TestPlugin_DefaultMaxHistory(t *testing.T) { |
| 149 | // NewPlugin without options should use the default (1000). |
nothing calls this directly
no test coverage detected