Skip to content

Commit 07e820d

Browse files
committed
Initial Commit
0 parents  commit 07e820d

8 files changed

+76
-0
lines changed

.idea/.gitignore

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/sqlite.iml

+11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# cosy-driver-mysql
2+
Sqlite Driver for Cosy

go.mod

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module git.uozi.org/uozi/cosy-driver-sqlite
2+
3+
go 1.22

sqlite.go

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package sqlite
2+
3+
import (
4+
"fmt"
5+
"github.com/0xJacky/cosy/settings"
6+
"gorm.io/driver/sqlite"
7+
"gorm.io/gorm"
8+
"path"
9+
)
10+
11+
func Open(dir string, dbs *settings.DataBase) gorm.Dialector {
12+
return sqlite.Open(path.Join(dir, fmt.Sprintf("%s.db", dbs.Name)))
13+
}

sqlite_test.go

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package sqlite
2+
3+
import (
4+
"github.com/0xJacky/cosy/settings"
5+
"gorm.io/driver/sqlite"
6+
"testing"
7+
)
8+
9+
func TestOpen(t *testing.T) {
10+
dbs := &settings.DataBase{
11+
Name: "cosy",
12+
}
13+
14+
dialector := Open("", dbs)
15+
16+
d, ok := dialector.(*sqlite.Dialector)
17+
if !ok {
18+
t.Fatal("dialector is not *Dialector")
19+
}
20+
if d.DSN == "" {
21+
t.Error("dialector.DSN is empty")
22+
}
23+
}

0 commit comments

Comments
 (0)