diff options
author | Julien Dessaux | 2024-10-05 09:54:35 +0200 |
---|---|---|
committer | Julien Dessaux | 2024-10-06 00:15:58 +0200 |
commit | c4ce5e86234e9f91599b87cff032228adb10fd50 (patch) | |
tree | bc328d23ccf4a4af68a055a62fbb6675905ec681 /pkg | |
parent | feat(tfstated): begin implementing tests (diff) | |
download | tfstated-c4ce5e86234e9f91599b87cff032228adb10fd50.tar.gz tfstated-c4ce5e86234e9f91599b87cff032228adb10fd50.tar.bz2 tfstated-c4ce5e86234e9f91599b87cff032228adb10fd50.zip |
fix(tfstated): add delete handler tests
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/database/states.go | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/pkg/database/states.go b/pkg/database/states.go index e848924..46a5536 100644 --- a/pkg/database/states.go +++ b/pkg/database/states.go @@ -5,9 +5,17 @@ import ( "fmt" ) -func (db *DB) DeleteState(name string) error { - _, err := db.Exec(`DELETE FROM states WHERE name = ?;`, name) - return err +// returns true in case of successful deletion +func (db *DB) DeleteState(name string) (bool, error) { + result, err := db.Exec(`DELETE FROM states WHERE name = ?;`, name) + if err != nil { + return false, err + } + n, err := result.RowsAffected() + if err != nil { + return false, err + } + return n == 1, nil } func (db *DB) GetState(name string) ([]byte, error) { |