Adding tests

This commit is contained in:
2025-11-04 14:41:49 -05:00
parent 13e0efb67c
commit 3e2efae4ce
3 changed files with 37 additions and 17 deletions

24
server/db/db_test.go Normal file
View File

@@ -0,0 +1,24 @@
package db
import (
"os"
"testing"
)
func TestConnect(t *testing.T) {
tmp_db, err := os.CreateTemp("", "vote_test.*.db")
tmp_db_name := tmp_db.Name()
tmp_db.Close()
defer os.Remove(tmp_db_name)
if err != nil {
t.Errorf(`Failed to create temporary db: %v`, err)
}
if err := Connect(tmp_db_name); err != nil {
t.Errorf(`Failed to create the database at %s: %v`, tmp_db_name, err)
}
defer Close()
}