summaryrefslogtreecommitdiff
path: root/pkg/database
diff options
context:
space:
mode:
authorJulien Dessaux2024-10-05 09:54:35 +0200
committerJulien Dessaux2024-10-06 00:15:58 +0200
commitc4ce5e86234e9f91599b87cff032228adb10fd50 (patch)
treebc328d23ccf4a4af68a055a62fbb6675905ec681 /pkg/database
parentfeat(tfstated): begin implementing tests (diff)
downloadtfstated-c4ce5e86234e9f91599b87cff032228adb10fd50.tar.gz
tfstated-c4ce5e86234e9f91599b87cff032228adb10fd50.tar.bz2
tfstated-c4ce5e86234e9f91599b87cff032228adb10fd50.zip
fix(tfstated): add delete handler tests
Diffstat (limited to '')
-rw-r--r--pkg/database/states.go14
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) {