...
1 package db
2
3 import (
4 "context"
5 "testing"
6
7 berrors "github.com/letsencrypt/boulder/errors"
8 "github.com/letsencrypt/boulder/test"
9 )
10
11 func TestRollback(t *testing.T) {
12 ctx := context.Background()
13 dbMap := testDbMap(t)
14
15 tx, _ := dbMap.BeginTx(ctx)
16
17 _ = tx.Commit()
18
19 innerErr := berrors.NotFoundError("Gone, gone, gone")
20 result := rollback(tx, innerErr)
21
22
23 test.AssertNotEquals(t, result, innerErr)
24 if rbErr, ok := result.(*RollbackError); ok {
25 test.AssertEquals(t, rbErr.Err, innerErr)
26 test.AssertNotNil(t, rbErr.RollbackErr, "RollbackErr was nil")
27 } else {
28 t.Fatalf("Result was not a RollbackError: %#v", result)
29 }
30
31
32
33 tx, _ = dbMap.BeginTx(ctx)
34 result = rollback(tx, innerErr)
35
36
37 test.AssertEquals(t, result, innerErr)
38 }
39
View as plain text