示例#1
0
文件: test.go 项目: brianz/empire
// NewServer builds a new empire.Empire instance and returns an httptest.Server
// running the empire API.
func NewServer(t testing.TB, e *empire.Empire) *Server {
	var opts server.Options
	opts.GitHub.Webhooks.Secret = "abcd"
	opts.Authenticator = auth.NewAccessTokenAuthenticator(e)
	opts.GitHub.Deployments.Environments = []string{"test"}
	opts.GitHub.Deployments.ImageBuilder = github.ImageFromTemplate(template.Must(template.New("image").Parse(github.DefaultTemplate)))
	return NewTestServer(t, e, opts)
}
示例#2
0
文件: test.go 项目: iserko/empire
// NewServer builds a new empire.Empire instance and returns an httptest.Server
// running the Empire API.
//
// The Server is unstarted so that you can perform additional configuration.
// Consumers should call Start() before makeing any requests.
func NewServer(t testing.TB, e *empire.Empire) *Server {
	var opts server.Options
	opts.GitHub.Webhooks.Secret = "abcd"
	opts.GitHub.Deployments.Environments = []string{"test"}
	opts.GitHub.Deployments.ImageBuilder = github.ImageFromTemplate(template.Must(template.New("image").Parse(github.DefaultTemplate)))
	s := newTestServer(t, e, opts)
	s.Heroku.Auth = &auth.Auth{}
	return s
}
示例#3
0
文件: test.go 项目: is00hcw/empire
// NewServer builds a new empire.Empire instance and returns an httptest.Server
// running the empire API.
func NewServer(t testing.TB, e *empire.Empire) *httptest.Server {
	if e == nil {
		e = NewEmpire(t)
	}

	server.DefaultOptions.GitHub.Webhooks.Secret = "abcd"
	server.DefaultOptions.Authenticator = auth.Anyone(&empire.User{Name: "fake"})
	server.DefaultOptions.GitHub.Deployments.Environments = []string{"test"}
	server.DefaultOptions.GitHub.Deployments.ImageBuilder = github.ImageFromTemplate(template.Must(template.New("image").Parse(github.DefaultTemplate)))
	return httptest.NewServer(server.New(e, server.DefaultOptions))
}
示例#4
0
文件: server.go 项目: iserko/empire
func newImageBuilder(c *Context) github.ImageBuilder {
	builder := c.String(FlagGithubDeploymentsImageBuilder)

	switch builder {
	case "template":
		tmpl := template.Must(template.New("image").Parse(c.String(FlagGithubDeploymentsImageTemplate)))
		return github.ImageFromTemplate(tmpl)
	case "conveyor":
		s := conveyor.NewService(conveyor.DefaultClient)
		s.URL = c.String(FlagConveyorURL)
		return github.NewConveyorImageBuilder(s)
	default:
		panic(fmt.Sprintf("unknown image builder: %s", builder))
	}
}
示例#5
0
文件: server.go 项目: is00hcw/empire
func newImageBuilder(c *cli.Context) github.ImageBuilder {
	tmpl := template.Must(template.New("image").Parse(c.String(FlagGithubDeploymentsImageTemplate)))
	return github.ImageFromTemplate(tmpl)
}