Skip to content

Commit

Permalink
chore: allow smtp jim config (#3932)
Browse files Browse the repository at this point in the history
  • Loading branch information
aeneasr committed May 21, 2024
1 parent 5dcbb77 commit 83792ef
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions x/mailhog.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func CleanUpTestSMTP() {
resources = nil
}

func RunTestSMTP() (smtp, api string, err error) {
func RunTestSMTP(options ...string) (smtp, api string, err error) {
if smtp, api := os.Getenv("TEST_MAILHOG_SMTP"), os.Getenv("TEST_MAILHOG_API"); smtp != "" && api != "" {
return smtp, api, nil
} else if len(smtp)+len(api) > 0 {
Expand All @@ -53,20 +53,24 @@ func RunTestSMTP() (smtp, api string, err error) {
}
smtpPort, apiPort := ports[0], ports[1]

if len(options) == 0 {
options = []string{
"-invite-jim",
"-jim-linkspeed-affect=0.05",
"-jim-reject-auth=0.05",
"-jim-reject-recipient=0.05",
"-jim-reject-sender=0.05",
"-jim-disconnect=0.05",
"-jim-linkspeed-min=1250",
"-jim-linkspeed-max=12500",
}
}

resource, err := pool.
RunWithOptions(&dockertest.RunOptions{
Repository: "mailhog/mailhog",
Tag: "v1.0.0",
Cmd: []string{
"-invite-jim",
"-jim-linkspeed-affect=0.05",
"-jim-reject-auth=0.05",
"-jim-reject-recipient=0.05",
"-jim-reject-sender=0.05",
"-jim-disconnect=0.05",
"-jim-linkspeed-min=1250",
"-jim-linkspeed-max=12500",
},
Cmd: options,
PortBindings: map[docker.Port][]docker.PortBinding{
"8025/tcp": {{HostPort: fmt.Sprintf("%d/tcp", apiPort)}},
"1025/tcp": {{HostPort: fmt.Sprintf("%d/tcp", smtpPort)}},
Expand Down

0 comments on commit 83792ef

Please sign in to comment.