mirror of
https://github.com/ddworken/hishtory.git
synced 2025-01-23 14:49:30 +01:00
goodbye to the Persist method that was silly
This commit is contained in:
parent
e2acc6612a
commit
843bcb32b3
@ -191,12 +191,6 @@ func OpenLocalSqliteDb() (*gorm.DB, error) {
|
|||||||
return db, nil
|
return db, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: DELETE THIS METHOD
|
|
||||||
func Persist(db *gorm.DB, entry HistoryEntry) error {
|
|
||||||
db.Create(&entry)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func Search(db *gorm.DB, query string, limit int) ([]*HistoryEntry, error) {
|
func Search(db *gorm.DB, query string, limit int) ([]*HistoryEntry, error) {
|
||||||
tokens, err := tokenize(query)
|
tokens, err := tokenize(query)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -11,7 +11,7 @@ func TestPersist(t *testing.T) {
|
|||||||
Check(t, err)
|
Check(t, err)
|
||||||
|
|
||||||
entry := MakeFakeHistoryEntry("ls ~/")
|
entry := MakeFakeHistoryEntry("ls ~/")
|
||||||
Check(t, Persist(db, entry))
|
db.Create(entry)
|
||||||
var historyEntries []*HistoryEntry
|
var historyEntries []*HistoryEntry
|
||||||
result := db.Find(&historyEntries)
|
result := db.Find(&historyEntries)
|
||||||
Check(t, result.Error)
|
Check(t, result.Error)
|
||||||
@ -32,9 +32,9 @@ func TestSearch(t *testing.T) {
|
|||||||
|
|
||||||
// Insert data
|
// Insert data
|
||||||
entry1 := MakeFakeHistoryEntry("ls /foo")
|
entry1 := MakeFakeHistoryEntry("ls /foo")
|
||||||
Check(t, Persist(db, entry1))
|
db.Create(entry1)
|
||||||
entry2 := MakeFakeHistoryEntry("ls /bar")
|
entry2 := MakeFakeHistoryEntry("ls /bar")
|
||||||
Check(t, Persist(db, entry2))
|
db.Create(entry2)
|
||||||
|
|
||||||
// Search for data
|
// Search for data
|
||||||
results, err := Search(db, "ls", 5)
|
results, err := Search(db, "ls", 5)
|
||||||
|
Loading…
Reference in New Issue
Block a user