func doSingleImport( t db.Transaction, store vsafedb.AddEntryRunner, jentry *jsonEntry, key *vsafe.Key) error { var entry vsafe.Entry var err error entry.Url, err = url.Parse(jentry.Url) if err != nil { return err } entry.Title = jentry.Title entry.Desc = jentry.Desc entry.UName = jentry.UName entry.Password = jentry.Password entry.Special = jentry.Special _, err = vsafedb.AddEntry(store, t, key, &entry) return err }
func UpdateEntry(t *testing.T, store UpdateEntryStore) { var first, second vsafe.Entry var firstResult, secondResult vsafe.Entry createEntries(t, store, &first, &second) first.Owner = 23 first.Url = url2 first.Title = "abar" first.Desc = "aaa" first.UName = "back" first.Password = "******" first.Special = "new again" if err := store.UpdateEntry(nil, &first); err != nil { t.Fatalf("Got error updating database: %v", err) } if err := store.EntryById(nil, first.Id, &firstResult); err != nil { t.Fatalf("Got error reading database by id: %v", err) } if err := store.EntryById(nil, second.Id, &secondResult); err != nil { t.Fatalf("Got error reading database by id: %v", err) } assertEntryEqual(t, &first, &firstResult) assertEntryEqual(t, &second, &secondResult) }