Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gosqlite
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gosqlite
Commits
3d6092ae
Commit
3d6092ae
authored
Mar 03, 2012
by
gwenn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use Logf in trace tests.
parent
b1be6529
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
15 deletions
+47
-15
trace_test.go
trace_test.go
+47
-15
No files found.
trace_test.go
View file @
3d6092ae
...
...
@@ -11,38 +11,70 @@ func init() {
}
func
trace
(
d
interface
{},
sql
string
)
{
//fmt.Printf("%s: %s\n", d, sql)
if
t
,
ok
:=
d
.
(
*
testing
.
T
);
ok
{
t
.
Logf
(
"TRACE: %s
\n
"
,
sql
)
}
else
{
fmt
.
Printf
(
"%s: %s
\n
"
,
d
,
sql
)
}
}
func
authorizer
(
d
interface
{},
action
Action
,
arg1
,
arg2
,
dbName
,
triggerName
string
)
Auth
{
//fmt.Printf("%s: %d, %s, %s, %s, %s\n", d, action, arg1, arg2, dbName, triggerName)
if
t
,
ok
:=
d
.
(
*
testing
.
T
);
ok
{
t
.
Logf
(
"AUTH: %d, %s, %s, %s, %s
\n
"
,
action
,
arg1
,
arg2
,
dbName
,
triggerName
)
}
else
{
fmt
.
Printf
(
"%s: %d, %s, %s, %s, %s
\n
"
,
d
,
action
,
arg1
,
arg2
,
dbName
,
triggerName
)
}
return
AUTH_OK
}
func
profile
(
d
interface
{},
sql
string
,
nanoseconds
uint64
)
{
//fmt.Printf("%s: %s = %d µs\n", d, sql, nanoseconds/1e3)
if
t
,
ok
:=
d
.
(
*
testing
.
T
);
ok
{
t
.
Logf
(
"PROFILE: %s = %d µs
\n
"
,
sql
,
nanoseconds
/
1e3
)
}
else
{
fmt
.
Printf
(
"%s: %s = %d µs
\n
"
,
d
,
sql
,
nanoseconds
/
1e3
)
}
}
func
progressHandler
(
d
interface
{})
bool
{
//fmt.Print("+")
if
t
,
ok
:=
d
.
(
*
testing
.
T
);
ok
{
t
.
Log
(
"+"
)
}
else
{
fmt
.
Print
(
"+"
)
}
return
false
}
func
commitHook
(
d
interface
{})
bool
{
if
t
,
ok
:=
d
.
(
*
testing
.
T
);
ok
{
t
.
Log
(
"CMT"
)
}
else
{
fmt
.
Printf
(
"%s
\n
"
,
d
)
}
return
false
}
func
rollbackHook
(
d
interface
{})
{
if
t
,
ok
:=
d
.
(
*
testing
.
T
);
ok
{
t
.
Log
(
"RBK"
)
}
else
{
fmt
.
Printf
(
"%s
\n
"
,
d
)
}
}
func
updateHook
(
d
interface
{},
a
Action
,
dbName
,
tableName
string
,
rowId
int64
)
{
if
t
,
ok
:=
d
.
(
*
testing
.
T
);
ok
{
t
.
Logf
(
"UPD: %d, %s.%s.%d
\n
"
,
a
,
dbName
,
tableName
,
rowId
)
}
else
{
fmt
.
Printf
(
"%s: %d, %s.%s.%d
\n
"
,
d
,
a
,
dbName
,
tableName
,
rowId
)
}
}
func
log
(
d
interface
{},
err
error
,
msg
string
)
{
if
t
,
ok
:=
d
.
(
*
testing
.
T
);
ok
{
t
.
Logf
(
"%s: %s
\n
"
,
err
,
msg
)
}
else
{
fmt
.
Printf
(
"%s: %s, %s
\n
"
,
d
,
err
,
msg
)
}
}
func
TestNoTrace
(
t
*
testing
.
T
)
{
...
...
@@ -63,14 +95,14 @@ func TestTrace(t *testing.T) {
db
,
err
:=
Open
(
""
)
checkNoError
(
t
,
err
,
"couldn't open database: %s"
)
defer
db
.
Close
()
db
.
Trace
(
trace
,
"TRACE"
)
err
=
db
.
SetAuthorizer
(
authorizer
,
"AUTH"
)
db
.
Trace
(
trace
,
t
)
err
=
db
.
SetAuthorizer
(
authorizer
,
t
)
checkNoError
(
t
,
err
,
"couldn't set an authorizer"
)
db
.
Profile
(
profile
,
"PROFILE"
)
db
.
ProgressHandler
(
progressHandler
,
1
,
nil
/*20*/
)
db
.
CommitHook
(
commitHook
,
"CMT"
)
db
.
RollbackHook
(
rollbackHook
,
"RBK"
)
db
.
UpdateHook
(
updateHook
,
"UPD"
)
db
.
Profile
(
profile
,
t
)
db
.
ProgressHandler
(
progressHandler
,
1
,
t
)
db
.
CommitHook
(
commitHook
,
t
)
db
.
RollbackHook
(
rollbackHook
,
t
)
db
.
UpdateHook
(
updateHook
,
t
)
db
.
Exists
(
"SELECT 1 WHERE 1 = ?"
,
1
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment