Skip to content

Instantly share code, notes, and snippets.

View mainawycliffe's full-sized avatar

Maina Wycliffe mainawycliffe

View GitHub Profile
// Yaml
viper.SetConfigType("yaml")
// JSON
viper.SetConfigType("json")
viper.SetConfigName("config-file-name");
viper.SetConfigName("config-file-name-2");
viper.AddConfigPath(".")
viper.AddConfigPath("$HOME/.looped")
viper.SetConfigFile("./path/to/config-file.yaml")
viper.SetConfigFile("./path/to/config-file-2.json")
// hard kill the container in 3 minutes (180 Seconds)
resource.Expire(180)
resp, err := http.Get(fmt.Sprintf("http://localhost:%s/api/v2/messages", HTTP_PORT))
assert.Nil(t, err)
defer resp.Body.Close()
assert.Equal(t, 200, resp.StatusCode)
body, err := ioutil.ReadAll(resp.Body)
mail := Mail{
host: SMTP_HOST,
port: SMTP_PORT,
from: "from@example.com",
password: "",
username: "",
}
err := mail.Send([]string{"to@example.com"}, "Test Subject", "Sending an automated test email")
assert.Nil(t, err)
func TestMain(m *testing.M) {
// uses a sensible default on windows (tcp/http) and linux/osx (socket)
pool, err := dockertest.NewPool("")
if err != nil {
log.Fatalf("Could not connect to docker: %s", err)
}
// we will use a dockerfile to build the image for testing
resource, err := pool.BuildAndRun("mailhog-test-server", "./Dockerfile", []string{})
if err != nil {
if err := pool.Purge(resource); err != nil {
log.Fatalf("Could not purge resource: %s", err)
}