MCPcopy
hub / github.com/go-sql-driver/mysql / TestIsolationLevelMapping

Function TestIsolationLevelMapping

utils_test.go:233–271  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

231}
232
233func TestIsolationLevelMapping(t *testing.T) {
234 data := []struct {
235 level driver.IsolationLevel
236 expected string
237 }{
238 {
239 level: driver.IsolationLevel(sql.LevelReadCommitted),
240 expected: "READ COMMITTED",
241 },
242 {
243 level: driver.IsolationLevel(sql.LevelRepeatableRead),
244 expected: "REPEATABLE READ",
245 },
246 {
247 level: driver.IsolationLevel(sql.LevelReadUncommitted),
248 expected: "READ UNCOMMITTED",
249 },
250 {
251 level: driver.IsolationLevel(sql.LevelSerializable),
252 expected: "SERIALIZABLE",
253 },
254 }
255
256 for i, td := range data {
257 if actual, err := mapIsolationLevel(td.level); actual != td.expected || err != nil {
258 t.Fatal(i, td.expected, actual, err)
259 }
260 }
261
262 // check unsupported mapping
263 expectedErr := "mysql: unsupported isolation level: 7"
264 actual, err := mapIsolationLevel(driver.IsolationLevel(sql.LevelLinearizable))
265 if actual != "" || err == nil {
266 t.Fatal("Expected error on unsupported isolation level")
267 }
268 if err.Error() != expectedErr {
269 t.Fatalf("Expected error to be %q, got %q", expectedErr, err)
270 }
271}
272
273func TestAppendDateTime(t *testing.T) {
274 tests := []struct {

Callers

nothing calls this directly

Calls 2

mapIsolationLevelFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected