Example #1
0
func new_container(env Environment) (*container_t, error) {

	if env.HttpAddr == "" {
		env.HttpAddr = ":3000"
	}

	db, err := store.Open(env.Database)
	if err != nil {
		return nil, err
	}

	src, err := store.OpenOld(env.Source)
	if err != nil {
		return nil, err
	}

	dst, err := store.OpenOld(env.Destination)
	if err != nil {
		return nil, err
	}

	c := &container_t{
		env:      env,
		app_map:  map[string]*Application{},
		database: db,
		src:      src,
		dst:      dst,
		shutdown: make(chan os.Signal, 1),
	}

	for _, factory := range app_registry {
		err := factory.build(c)
		if err != nil {
			return nil, err
		}
	}

	// reset the host router
	c.router.Reset()

	return c, nil
}
Example #2
0
func Golden(t *testing.T, g static.Generator) {
	runtime.GOMAXPROCS(runtime.NumCPU() * 2)

	wd, err := os.Getwd()
	if err != nil {
		t.Fatal(err)
	}

	db, err := store.Open("")
	if err != nil {
		t.Fatal(err)
	}

	src, err := store.OpenOld("file://" + path.Join(wd, "test/src"))
	if err != nil {
		t.Fatal(err)
	}

	dst, err := store.OpenOld("file://" + path.Join(wd, "test/dst"))
	if err != nil {
		t.Fatal(err)
	}

	os.RemoveAll(path.Join(wd, "test/dst"))

	err = static.Generate(
		src,
		dst,
		db,
		g,
	)

	if err != nil {
		t.Fatal(err)
	}
}