Merge pull request #55 from wneessen/more_testcoverage

Add test for excluded characters in config
This commit is contained in:
Winni Neessen 2024-03-14 21:46:48 +01:00 committed by GitHub
commit da910fde14
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -220,6 +220,23 @@ func TestGetCharRangeFromConfig(t *testing.T) {
}
}
func TestGetCharRangeFromConfig_ExcludeChar(t *testing.T) {
defaultConf := NewConfig()
defaultGen := New(defaultConf)
defaultRange := defaultGen.GetCharRangeFromConfig()
defaultRange = strings.ReplaceAll(defaultRange, "a", "")
defaultRange = strings.ReplaceAll(defaultRange, "b", "")
config := NewConfig(WithExcludeChars("ab"))
generator := New(config)
excludeRange := generator.GetCharRangeFromConfig()
if excludeRange != defaultRange {
t.Errorf("GetCharRangeFromConfig(WithExcludeChars()) failed. Expected"+
"char range: %s, got: %s", defaultRange, excludeRange)
}
}
func TestGetPasswordLength(t *testing.T) {
config := NewConfig()
generator := New(config)