diff options
Diffstat (limited to 'db')
-rw-r--r-- | db/setup.go | 27 | ||||
-rw-r--r-- | db/setup_test.go | 29 | ||||
-rw-r--r-- | db/testdata/test.db | bin | 12288 -> 0 bytes |
3 files changed, 0 insertions, 56 deletions
diff --git a/db/setup.go b/db/setup.go deleted file mode 100644 index 5cd1041..0000000 --- a/db/setup.go +++ /dev/null @@ -1,27 +0,0 @@ -package db - -import ( - "database/sql" - "errors" - "log" - "os" - - _ "github.com/mattn/go-sqlite3" -) - -func SetupDB(path string) (*sql.DB, error) { - os.Create(path) - db, err := sql.Open("sqlite3", path) - if err != nil { - return db, errors.New("Cannot open that damn database file") - } - stmt := `drop table if exists datamap; - create table datamap(id integer no null primary key, name text); - ` - _, err = db.Exec(stmt) - if err != nil { - log.Printf("%q: %s\n", err, stmt) - } - - return db, nil -} diff --git a/db/setup_test.go b/db/setup_test.go deleted file mode 100644 index e256f9c..0000000 --- a/db/setup_test.go +++ /dev/null @@ -1,29 +0,0 @@ -package db - -import "testing" - -func TestOpenSQLiteFile(t *testing.T) { - // db, err := sql.Open("sqlite3", "testdata/test.db") - db, err := SetupDB("./testdata/test.db") - defer db.Close() - if err != nil { - t.Fatal("Expected to be able to set up the database.") - } - stmt := `insert into datamap(id, name) values(1,'cock')` - _, err = db.Exec(stmt) - if err != nil { - t.Errorf("Cannot add record to db") - } - rows, err := db.Query("select name from datamap") - if err != nil { - t.Errorf("Cannot run select statement") - } - defer rows.Close() - for rows.Next() { - var name string - err = rows.Scan(&name) - if err != nil { - t.Errorf("Cannot scan resulting row") - } - } -} diff --git a/db/testdata/test.db b/db/testdata/test.db Binary files differdeleted file mode 100644 index 8a7fa2f..0000000 --- a/db/testdata/test.db +++ /dev/null |