1
0

Fix build when using go modules (#6)

This commit is contained in:
konrad
2018-10-28 16:11:13 +00:00
committed by Gitea
parent 738c22b5f9
commit 321c0f2404
495 changed files with 140271 additions and 370 deletions

View File

@ -13,14 +13,14 @@ var Queue chan *gomail.Message
// StartMailDaemon starts the mail daemon
func StartMailDaemon() {
Queue = make(chan *gomail.Message, viper.GetInt("mailer.queuelength"))
if viper.GetString("mailer.host") == "" {
//models.Log.Warning("Mailer seems to be not configured! Please see the config docs for more details.")
fmt.Println("Mailer seems to be not configured! Please see the config docs for more details.")
return
}
Queue = make(chan *gomail.Message, viper.GetInt("mailer.queuelength"))
go func() {
d := gomail.NewDialer(viper.GetString("mailer.host"), viper.GetInt("mailer.port"), viper.GetString("mailer.username"), viper.GetString("mailer.password"))
d.TLSConfig = &tls.Config{InsecureSkipVerify: viper.GetBool("mailer.skiptlsverify")}

View File

@ -1,6 +1,7 @@
package models
import (
"code.vikunja.io/api/models/mail"
"fmt"
"github.com/go-xorm/core"
"github.com/go-xorm/xorm"
@ -10,6 +11,10 @@ import (
"testing"
)
// IsTesting is set to true when we're running tests.
// We don't have a good solution to test email sending yet, so we disable email sending when testing
var IsTesting bool
// MainTest creates the test engine
func MainTest(m *testing.M, pathToRoot string) {
var err error
@ -19,6 +24,11 @@ func MainTest(m *testing.M, pathToRoot string) {
os.Exit(1)
}
IsTesting = true
// Start the pseudo mail queue
mail.StartMailDaemon()
// Create test database
PrepareTestDatabase()

View File

@ -42,6 +42,11 @@ func UserPasswordReset(reset *PasswordReset) (err error) {
return
}
// Dont send a mail if we're testing
if IsTesting {
return
}
// Send a mail to the user to notify it his password was changed.
data := map[string]interface{}{
"User": user,
@ -74,6 +79,11 @@ func RequestUserPasswordResetToken(tr *PasswordTokenRequest) (err error) {
return
}
// Dont send a mail if we're testing
if IsTesting {
return
}
data := map[string]interface{}{
"User": user,
}

View File

@ -122,7 +122,7 @@ func TestCreateUser(t *testing.T) {
func TestUserPasswordReset(t *testing.T) {
// Request a new token
tr := &PasswordTokenRequest{
UserID: 1,
Username: "user1",
}
err := RequestUserPasswordResetToken(tr)
assert.NoError(t, err)