This repository has been archived by the owner on Dec 5, 2024. It is now read-only.
forked from gopasspw/gopass
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[bugfix] Default to true for core.exportkeys even in substores (gopas…
…spw#2848) * [bugfix] Default to true for core.exportkeys even in substores This PR changes the default for core.exportkeys from false to true in mounted substores to match the default of the global root store. It also refactors and simplifies the config package a little bit by removing special typed lookup methods and replacing them with conversion helpers that can be applied to any string. Fixes gopasspw#2830 Signed-off-by: Dominik Schulz <[email protected]> * Fix config tests Signed-off-by: Dominik Schulz <[email protected]> --------- Signed-off-by: Dominik Schulz <[email protected]>
- Loading branch information
1 parent
9b41761
commit 2adc544
Showing
11 changed files
with
163 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package config | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestAsBoolWithDefault(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
s string | ||
def bool | ||
expected bool | ||
}{ | ||
{ | ||
name: "Empty string with default true", | ||
s: "", | ||
def: true, | ||
expected: true, | ||
}, | ||
{ | ||
name: "Empty string with default false", | ||
s: "", | ||
def: false, | ||
expected: false, | ||
}, | ||
{ | ||
name: "Valid string '1' with default true", | ||
s: "1", | ||
def: true, | ||
expected: true, | ||
}, | ||
{ | ||
name: "Valid string '0' with default true", | ||
s: "0", | ||
def: true, | ||
expected: false, | ||
}, | ||
// Add more test cases here | ||
} | ||
|
||
for _, test := range tests { | ||
t.Run(test.name, func(t *testing.T) { | ||
result := AsBoolWithDefault(test.s, test.def) | ||
if result != test.expected { | ||
t.Errorf("Expected %v, but got %v", test.expected, result) | ||
} | ||
}) | ||
} | ||
} | ||
|
||
func TestAsIntWithDefault(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
s string | ||
def int | ||
expected int | ||
}{ | ||
{ | ||
name: "Empty string with default 0", | ||
s: "", | ||
def: 0, | ||
expected: 0, | ||
}, | ||
{ | ||
name: "Valid string '123' with default 0", | ||
s: "123", | ||
def: 0, | ||
expected: 123, | ||
}, | ||
{ | ||
name: "Invalid string 'abc' with default 0", | ||
s: "abc", | ||
def: 0, | ||
expected: 0, | ||
}, | ||
// Add more test cases here | ||
} | ||
|
||
for _, test := range tests { | ||
t.Run(test.name, func(t *testing.T) { | ||
result := AsIntWithDefault(test.s, test.def) | ||
if result != test.expected { | ||
t.Errorf("Expected %v, but got %v", test.expected, result) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters