31 lines
689 B
Go
31 lines
689 B
Go
|
|
package main
|
||
|
|
|
||
|
|
import (
|
||
|
|
"fmt"
|
||
|
|
"io/ioutil"
|
||
|
|
"path"
|
||
|
|
"testing"
|
||
|
|
|
||
|
|
yaml "gopkg.in/yaml.v2"
|
||
|
|
)
|
||
|
|
|
||
|
|
func TestSendMail(t *testing.T) {
|
||
|
|
db := GetDB()
|
||
|
|
config := Config{}
|
||
|
|
configPath := path.Join(ROOT_DIR, "data/config/config.yaml")
|
||
|
|
configBytes, err := ioutil.ReadFile(configPath)
|
||
|
|
|
||
|
|
if err != nil {
|
||
|
|
panic(fmt.Sprintf("Can't open config file at %s; %v", configPath, err))
|
||
|
|
}
|
||
|
|
|
||
|
|
if err := yaml.Unmarshal([]byte(configBytes), &config); err != nil {
|
||
|
|
panic(fmt.Sprintf("Can't parse config file at %s; %v", configPath, err))
|
||
|
|
}
|
||
|
|
|
||
|
|
preOrder := PreOrder{}
|
||
|
|
|
||
|
|
db.Preload("Items").Preload("Items.Product").Where("id = ?", "66297049-6019-45a3-bb98-959d4c2476d9").Find(&preOrder)
|
||
|
|
sendMail(preOrder, config)
|
||
|
|
}
|