Example #1
0
func TestGetenv(t *testing.T) {
	func() {
		actual := kocha.Getenv("TEST_KOCHA_ENV", "default value")
		expected := "default value"
		if !reflect.DeepEqual(actual, expected) {
			t.Errorf("Getenv(%q, %q) => %q, want %q", "TEST_KOCHA_ENV", "default value", actual, expected)
		}

		actual = os.Getenv("TEST_KOCHA_ENV")
		expected = "default value"
		if !reflect.DeepEqual(actual, expected) {
			t.Errorf("os.Getenv(%q) => %q, want %q", "TEST_KOCHA_ENV", actual, expected)
		}
	}()

	func() {
		os.Setenv("TEST_KOCHA_ENV", "set kocha env")
		defer os.Clearenv()
		actual := kocha.Getenv("TEST_KOCHA_ENV", "default value")
		expected := "set kocha env"
		if !reflect.DeepEqual(actual, expected) {
			t.Errorf("Getenv(%q, %q) => %q, want %q", "TEST_KOCHA_ENV", "default value", actual, expected)
		}

		actual = os.Getenv("TEST_KOCHA_ENV")
		expected = "set kocha env"
		if !reflect.DeepEqual(actual, expected) {
			t.Errorf("os.Getenv(%q) => %q, want %q", "TEST_KOCHA_ENV", actual, expected)
		}
	}()
}
Example #2
0
package config

import (
	"os"
	"path/filepath"
	"runtime"
	"time"

	"github.com/woremacx/kocha"
	"github.com/woremacx/kocha/log"
)

var (
	AppName   = "testappname"
	AppConfig = &kocha.Config{
		Addr:          kocha.Getenv("KOCHA_ADDR", "127.0.0.1:9100"),
		AppPath:       rootPath,
		AppName:       AppName,
		DefaultLayout: "app",
		Template: &kocha.Template{
			PathInfo: kocha.TemplatePathInfo{
				Name: AppName,
				Paths: []string{
					filepath.Join(rootPath, "app", "view"),
				},
			},
			FuncMap: kocha.TemplateFuncMap{},
		},

		// Logger settings.
		Logger: &kocha.LoggerConfig{