Skip to content

Commit d10d2ca

Browse files
helloeveYuan325
andauthored
fix: prevent test.db from being created during unit tests (#3042)
This PR updates the unit tests to use in-memory SQLite databases (:memory:) instead of creating physical test.db files on disk. While using tmp directory for managing the test.db file is a plausible approach, it will encounter file-locking conflicts on Windows during test cleanup which prevents the clean-up of database files located in tmp directory. --------- Co-authored-by: Yuan Teoh <45984206+Yuan325@users.noreply.github.com>
1 parent 5fdc00a commit d10d2ca

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

cmd/internal/invoke/command_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func TestInvokeTool(t *testing.T) {
5252
sources:
5353
my-sqlite:
5454
kind: sqlite
55-
database: test.db
55+
database: ":memory:"
5656
tools:
5757
hello-sqlite:
5858
kind: sqlite-sql

cmd/internal/skills/command_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func TestGenerateSkill(t *testing.T) {
5959
sources:
6060
my-sqlite:
6161
kind: sqlite
62-
database: test.db
62+
database: ":memory:"
6363
tools:
6464
hello-sqlite:
6565
kind: sqlite-sql
@@ -158,7 +158,7 @@ func TestGenerateSkill_Toolsets(t *testing.T) {
158158
sources:
159159
my-sqlite:
160160
kind: sqlite
161-
database: test.db
161+
database: ":memory:"
162162
tools:
163163
hello-sqlite:
164164
kind: sqlite-sql
@@ -247,7 +247,7 @@ func TestGenerateSkill_SpecificToolset(t *testing.T) {
247247
sources:
248248
my-sqlite:
249249
kind: sqlite
250-
database: test.db
250+
database: ":memory:"
251251
tools:
252252
hello-sqlite:
253253
kind: sqlite-sql

cmd/root_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ func TestFileLoadingErrors(t *testing.T) {
699699
}
700700

701701
func TestPrebuiltAndCustomTools(t *testing.T) {
702-
t.Setenv("SQLITE_DATABASE", "test.db")
702+
t.Setenv("SQLITE_DATABASE", "\":memory:\"")
703703
// Setup custom config
704704
customContent := `
705705
kind: tool
@@ -867,7 +867,7 @@ tools:
867867
}
868868

869869
func TestDefaultConfigBehavior(t *testing.T) {
870-
t.Setenv("SQLITE_DATABASE", "test.db")
870+
t.Setenv("SQLITE_DATABASE", "\":memory:\"")
871871
testCases := []struct {
872872
desc string
873873
args []string

0 commit comments

Comments
 (0)