aboutsummaryrefslogtreecommitdiffstats
path: root/repository/mock_repo.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2019-05-27 21:18:46 +0200
committerMichael Muré <batolettre@gmail.com>2019-05-27 21:39:55 +0200
commitd564e37b317a2d59a9694d80b03b40e5d36f741f (patch)
treeba6bcdca38286372293b65f3c0b087cf95c066a1 /repository/mock_repo.go
parentc7abac388aadd274d4f23f996a15f8bba90f2a92 (diff)
downloadgit-bug-d564e37b317a2d59a9694d80b03b40e5d36f741f.tar.gz
repository: add ReadConfigBool and ReadConfigString functions
Diffstat (limited to 'repository/mock_repo.go')
-rw-r--r--repository/mock_repo.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/repository/mock_repo.go b/repository/mock_repo.go
index 97a4504f..14f5e7b5 100644
--- a/repository/mock_repo.go
+++ b/repository/mock_repo.go
@@ -3,6 +3,7 @@ package repository
import (
"crypto/sha1"
"fmt"
+ "strconv"
"strings"
"github.com/MichaelMure/git-bug/util/git"
@@ -75,6 +76,26 @@ func (r *mockRepoForTest) ReadConfigs(keyPrefix string) (map[string]string, erro
return result, nil
}
+func (r *mockRepoForTest) ReadConfigBool(key string) (bool, error) {
+ // unlike git, the mock can only store one value for the same key
+ val, ok := r.config[key]
+ if !ok {
+ return false, ErrNoConfigEntry
+ }
+
+ return strconv.ParseBool(val)
+}
+
+func (r *mockRepoForTest) ReadConfigString(key string) (string, error) {
+ // unlike git, the mock can only store one value for the same key
+ val, ok := r.config[key]
+ if !ok {
+ return "", ErrNoConfigEntry
+ }
+
+ return val, nil
+}
+
func (r *mockRepoForTest) RmConfigs(keyPrefix string) error {
for key := range r.config {
if strings.HasPrefix(key, keyPrefix) {