Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #64 from projectdiscovery/issue-63-retry
Adding retry positive validation
- Loading branch information
Showing
4 changed files
with
37 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,20 @@ | ||
package retryabledns | ||
|
||
import "time" | ||
import ( | ||
"errors" | ||
"time" | ||
) | ||
|
||
type Options struct { | ||
BaseResolvers []string | ||
MaxRetries int | ||
Timeout time.Duration | ||
Hostsfile bool | ||
} | ||
|
||
func (options *Options) Validate() error { | ||
if options.MaxRetries == 0 { | ||
return errors.New("retries must be at least 1") | ||
} | ||
return nil | ||
} |
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,13 @@ | ||
package retryabledns | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestValidateOptions(t *testing.T) { | ||
options := Options{} | ||
err := options.Validate() | ||
require.NotNil(t, err) | ||
} |