mirror of
https://github.com/ddworken/hishtory.git
synced 2024-11-23 08:45:16 +01:00
more tests + some todos where I could add even more
This commit is contained in:
parent
64935391b6
commit
ac18b3d93e
@ -417,3 +417,5 @@ func TestGithubRedirects(t *testing.T) {
|
||||
t.Fatalf("response is too short to be a binary, resp=%d", len(respBody))
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Maybe a dedicated unit test for retrieveAdditionalEntriesFromRemote
|
||||
|
@ -48,3 +48,5 @@ func TestParseTimeGenerously(t *testing.T) {
|
||||
t.Fatalf("parsed time incorrectly: %d", ts.Unix())
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Maybe some dedicated unit tests for Search()
|
||||
|
@ -123,3 +123,31 @@ func TestSearch(t *testing.T) {
|
||||
t.Fatalf("Search()[0]=%#v, expected: %#v", results[1], entry1)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAddToDbIfNew(t *testing.T) {
|
||||
// Set up
|
||||
defer shared.BackupAndRestore(t)()
|
||||
db, err := OpenLocalSqliteDb()
|
||||
shared.Check(t, err)
|
||||
|
||||
// Add duplicate entries
|
||||
entry1 := data.MakeFakeHistoryEntry("ls /foo")
|
||||
AddToDbIfNew(db, entry1)
|
||||
AddToDbIfNew(db, entry1)
|
||||
entry2 := data.MakeFakeHistoryEntry("ls /foo")
|
||||
AddToDbIfNew(db, entry2)
|
||||
AddToDbIfNew(db, entry2)
|
||||
AddToDbIfNew(db, entry1)
|
||||
|
||||
// Check there should only be two entries
|
||||
var entries []data.HistoryEntry
|
||||
result := db.Find(&entries)
|
||||
if result.Error != nil {
|
||||
t.Fatal(result.Error)
|
||||
}
|
||||
if len(entries) != 2 {
|
||||
t.Fatalf("entries has an incorrect length: %d", len(entries))
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Some day find a way of testing the table display
|
||||
|
Loading…
Reference in New Issue
Block a user