Skip to content

Commit

Permalink
[Jasoet] Merge utility helper to particular app
Browse files Browse the repository at this point in the history
  • Loading branch information
jasoet committed Aug 5, 2019
1 parent 53c643e commit e934aed
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 92 deletions.
2 changes: 1 addition & 1 deletion internal/app/cli/command/list/lister.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

"github.com/fatih/color"
"github.com/spf13/cobra"
"proctor/internal/pkg/utility/sort"
"proctor/internal/app/cli/sort"
)

func NewCmd(printer io.Printer, proctorDClient daemon.Client) *cobra.Command {
Expand Down
File renamed without changes.
File renamed without changes.
12 changes: 10 additions & 2 deletions internal/app/service/infra/mail/mailer.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package mail

import (
"bytes"
"fmt"
"net/smtp"
"strings"

executionContextModel "proctor/internal/app/service/execution/model"
"proctor/internal/app/service/infra/config"
scheduleModel "proctor/internal/app/service/schedule/model"
"proctor/internal/pkg/utility"
)

type Mailer interface {
Expand Down Expand Up @@ -42,10 +42,18 @@ func constructMessage(jobName string, executionID uint64, executionStatus string
subject := "Subject: " + jobName + " | scheduled execution " + executionStatus
body := "Proc execution details:\n" +
"\nName:\t" + jobName +
"\nArgs:\t" + utility.MapToString(executionArgs) +
"\nArgs:\t" + MapToString(executionArgs) +
"\nID:\t" + fmt.Sprint(executionID) +
"\nStatus:\t" + executionStatus +
"\n\n\nThis is an auto-generated email"

return []byte(subject + "\n\n" + body)
}

func MapToString(someMap map[string]string) string {
b := new(bytes.Buffer)
for key, value := range someMap {
_, _ = fmt.Fprintf(b, "%s=\"%s\",", key, value)
}
return strings.TrimRight(b.String(), ",")
}
3 changes: 1 addition & 2 deletions internal/app/service/infra/mail/mailer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
executionStatus "proctor/internal/app/service/execution/status"
"proctor/internal/app/service/infra/config"
scheduleModel "proctor/internal/app/service/schedule/model"
"proctor/internal/pkg/utility"
)

func TestSendMail(t *testing.T) {
Expand Down Expand Up @@ -98,7 +97,7 @@ func TestSendMail(t *testing.T) {

receivedMail := cmdbuf.String()

stringifiedJobArgs := utility.MapToString(executionContext.Args)
stringifiedJobArgs := MapToString(executionContext.Args)
var sendMailClient = `EHLO localhost
HELO localhost
MAIL FROM:<` + config.MailUsername() + `>
Expand Down
43 changes: 0 additions & 43 deletions internal/pkg/utility/buffer.go

This file was deleted.

44 changes: 0 additions & 44 deletions internal/pkg/utility/utils.go

This file was deleted.

0 comments on commit e934aed

Please sign in to comment.