package config

import (
	"os"
	"testing"
)

func TestNew(t *testing.T) {
	invalidEnv := "&&&&&&"
	keys := []string{
		"DB",
		"DATABASE",
		"ADDR",
		"PATH",
		"USER",
		"USERNAME",
		"PASS",
		"PASSWORD",
	}
	was := make(map[string]string)
	for _, k := range keys {
		v, ok := os.LookupEnv(k)
		if !ok {
			v = invalidEnv
		}
		was[k] = v
	}
	defer func() {
		for k, v := range was {
			if v != invalidEnv {
				os.Setenv(k, v)
			} else {
				os.Unsetenv(k)
			}
		}
	}()
	os.Args = []string{"a", "-db", "map"}
	if err := New(); err != nil {
		t.Fatal(err)
	}
}
