Skip to content

Commit 9c05588

Browse files
committed
✅ Add test for go-sqlite3 op code
A test to check that the opcode of a query from go-sqlite3 matches the one from the rpc packages
1 parent 1fe8e93 commit 9c05588

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

module/module_test.go

+21
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ var schema3 = rpc.DatabaseSchema{
7070
}
7171

7272
func TestCreateSQLiteSchema(t *testing.T) {
73+
t.Parallel()
7374
type args struct {
7475
schema rpc.DatabaseSchema
7576
expected string
@@ -103,6 +104,7 @@ func TestCreateSQLiteSchema(t *testing.T) {
103104
}
104105

105106
func TestRawPlugin(t *testing.T) {
107+
t.Parallel()
106108
// Build the raw plugin
107109
os.Mkdir("_test", 0755)
108110
err := exec.Command("go", "build", "-o", "_test/test.out", "../test/rawplugin.go").Run()
@@ -188,6 +190,7 @@ func TestRawPlugin(t *testing.T) {
188190
}
189191

190192
func TestRawPlugin2(t *testing.T) {
193+
t.Parallel()
191194
// Build the raw plugin
192195
os.Mkdir("_test", 0755)
193196
err := exec.Command("go", "build", "-o", "_test/test2.out", "../test/rawplugin2.go").Run()
@@ -280,3 +283,21 @@ func TestRawPlugin2(t *testing.T) {
280283
})
281284

282285
}
286+
287+
func TestOpCode(t *testing.T) {
288+
t.Parallel()
289+
// This test ensure that the go-sqlite3 keeps the same opcode
290+
291+
assert.Equal(t, int(sqlite3.OpEQ), int(rpc.OperatorEqual), "The opcode EQ must be the same")
292+
assert.Equal(t, int(sqlite3.OpLT), int(rpc.OperatorLess), "The opcode LT must be the same")
293+
assert.Equal(t, int(sqlite3.OpLE), int(rpc.OperatorLessOrEqual), "The opcode LE must be the same")
294+
assert.Equal(t, int(sqlite3.OpGT), int(rpc.OperatorGreater), "The opcode GT must be the same")
295+
assert.Equal(t, int(sqlite3.OpGE), int(rpc.OperatorGreaterOrEqual), "The opcode GE must be the same")
296+
assert.Equal(t, int(sqlite3.OpLIKE), int(rpc.OperatorLike), "The opcode LIKE must be the same")
297+
assert.Equal(t, int(sqlite3.OpGLOB), int(rpc.OperatorGlob), "The opcode GLOB must be the same")
298+
assert.Equal(t, int(sqlite3.OpMATCH), int(rpc.OperatorMatch), "The opcode MATCH must be the same")
299+
assert.Equal(t, int(sqlite3.OpREGEXP), int(rpc.OperatorRegexp), "The opcode REGEXP must be the same")
300+
assert.Equal(t, int(sqlite3.OpLIMIT), int(rpc.OperatorLimit), "The opcode LIMIT must be the same")
301+
assert.Equal(t, int(sqlite3.OpOFFSET), int(rpc.OperatorOffset), "The opcode OFFSET must be the same")
302+
303+
}

0 commit comments

Comments
 (0)