-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mailing list tests now use the mock server
- Loading branch information
Showing
11 changed files
with
468 additions
and
163 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package mailgun_test | ||
|
||
import ( | ||
"crypto/rand" | ||
"fmt" | ||
"strings" | ||
) | ||
|
||
// randomString generates a string of given length, but random content. | ||
// All content will be within the ASCII graphic character set. | ||
// (Implementation from Even Shaw's contribution on | ||
// http://stackoverflow.com/questions/12771930/what-is-the-fastest-way-to-generate-a-long-random-string-in-go). | ||
func randomString(n int, prefix string) string { | ||
const alphanum = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" | ||
var bytes = make([]byte, n) | ||
rand.Read(bytes) | ||
for i, b := range bytes { | ||
bytes[i] = alphanum[b%byte(len(alphanum))] | ||
} | ||
return prefix + string(bytes) | ||
} | ||
|
||
func randomEmail(prefix, domain string) string { | ||
return strings.ToLower(fmt.Sprintf("%s@%s", randomString(20, prefix), domain)) | ||
} |
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
Oops, something went wrong.