database: fix keyvalue/notification tests
This commit is contained in:
parent
563b3825d8
commit
21f152c03e
@ -14,7 +14,11 @@
|
|||||||
|
|
||||||
package pgsql
|
package pgsql
|
||||||
|
|
||||||
import cerrors "github.com/coreos/clair/utils/errors"
|
import (
|
||||||
|
"database/sql"
|
||||||
|
|
||||||
|
cerrors "github.com/coreos/clair/utils/errors"
|
||||||
|
)
|
||||||
|
|
||||||
// InsertKeyValue stores (or updates) a single key / value tuple.
|
// InsertKeyValue stores (or updates) a single key / value tuple.
|
||||||
func (pgSQL *pgSQL) InsertKeyValue(key, value string) (err error) {
|
func (pgSQL *pgSQL) InsertKeyValue(key, value string) (err error) {
|
||||||
@ -62,6 +66,10 @@ func (pgSQL *pgSQL) InsertKeyValue(key, value string) (err error) {
|
|||||||
func (pgSQL *pgSQL) GetKeyValue(key string) (string, error) {
|
func (pgSQL *pgSQL) GetKeyValue(key string) (string, error) {
|
||||||
var value string
|
var value string
|
||||||
err := pgSQL.QueryRow(getQuery("s_keyvalue"), key).Scan(&value)
|
err := pgSQL.QueryRow(getQuery("s_keyvalue"), key).Scan(&value)
|
||||||
|
|
||||||
|
if err == sql.ErrNoRows {
|
||||||
|
return "", nil
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", handleError("s_keyvalue", err)
|
return "", handleError("s_keyvalue", err)
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ import (
|
|||||||
|
|
||||||
// do it in tx so we won't insert/update a vuln without notification and vice-versa.
|
// do it in tx so we won't insert/update a vuln without notification and vice-versa.
|
||||||
func (pgSQL *pgSQL) insertNotification(tx *sql.Tx, notification interface{}) error {
|
func (pgSQL *pgSQL) insertNotification(tx *sql.Tx, notification interface{}) error {
|
||||||
kind := reflect.Indirect(reflect.ValueOf(notification)).Type()
|
kind := reflect.Indirect(reflect.ValueOf(notification)).Type().String()
|
||||||
data, err := json.Marshal(notification)
|
data, err := json.Marshal(notification)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
tx.Rollback()
|
tx.Rollback()
|
||||||
|
Loading…
Reference in New Issue
Block a user