summaryrefslogtreecommitdiffstats
path: root/pkg/commands/config_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/commands/config_test.go')
-rw-r--r--pkg/commands/config_test.go70
1 files changed, 70 insertions, 0 deletions
diff --git a/pkg/commands/config_test.go b/pkg/commands/config_test.go
new file mode 100644
index 000000000..c16b53901
--- /dev/null
+++ b/pkg/commands/config_test.go
@@ -0,0 +1,70 @@
+package commands
+
+import (
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+)
+
+// TestGitCommandUsingGpg is a function.
+func TestGitCommandUsingGpg(t *testing.T) {
+ type scenario struct {
+ testName string
+ getGitConfigValue func(string) (string, error)
+ test func(bool)
+ }
+
+ scenarios := []scenario{
+ {
+ "Option global and local config commit.gpgsign is not set",
+ func(string) (string, error) { return "", nil },
+ func(gpgEnabled bool) {
+ assert.False(t, gpgEnabled)
+ },
+ },
+ {
+ "Option commit.gpgsign is true",
+ func(string) (string, error) {
+ return "True", nil
+ },
+ func(gpgEnabled bool) {
+ assert.True(t, gpgEnabled)
+ },
+ },
+ {
+ "Option commit.gpgsign is on",
+ func(string) (string, error) {
+ return "ON", nil
+ },
+ func(gpgEnabled bool) {
+ assert.True(t, gpgEnabled)
+ },
+ },
+ {
+ "Option commit.gpgsign is yes",
+ func(string) (string, error) {
+ return "YeS", nil
+ },
+ func(gpgEnabled bool) {
+ assert.True(t, gpgEnabled)
+ },
+ },
+ {
+ "Option commit.gpgsign is 1",
+ func(string) (string, error) {
+ return "1", nil
+ },
+ func(gpgEnabled bool) {
+ assert.True(t, gpgEnabled)
+ },
+ },
+ }
+
+ for _, s := range scenarios {
+ t.Run(s.testName, func(t *testing.T) {
+ gitCmd := NewDummyGitCommand()
+ gitCmd.getGitConfigValue = s.getGitConfigValue
+ s.test(gitCmd.UsingGpg())
+ })
+ }
+}