示例#1
0
文件: test.go 项目: frewsxcv/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.GitHub.Deployments.Environment = "test"
	server.DefaultOptions.Authenticator = auth.Anyone(&empire.User{Name: "fake"})
	return httptest.NewServer(server.New(e, server.DefaultOptions))
}
示例#2
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))
}
示例#3
0
文件: api_test.go 项目: brianz/empire
// NewTestClient will return a new heroku.Client that's configured to interact
// with a instance of the empire HTTP server.
func NewTestClient(t testing.TB) (*heroku.Client, *empiretest.Server) {
	e := empiretest.NewEmpire(t)
	s := empiretest.NewTestServer(t, e, server.Options{
		Authenticator: auth.Anyone(&empire.User{Name: "fake"}),
	})

	c := &heroku.Client{
		Username: "",
		Password: "",
	}
	c.URL = s.URL

	return c, s
}
示例#4
0
文件: api_test.go 项目: iserko/empire
// NewTestClient will return a new heroku.Client that's configured to interact
// with a instance of the empire HTTP server.
func NewTestClient(t testing.TB) (*heroku.Client, *empiretest.Server) {
	e := empiretest.NewEmpire(t)
	s := empiretest.NewServer(t, e)
	s.Heroku.Auth = &auth.Auth{
		Strategies: auth.Strategies{
			{
				Name:          auth.StrategyUsernamePassword,
				Authenticator: auth.Anyone(&empire.User{Name: "fake"}),
			},
		},
	}
	s.Start()

	c := &heroku.Client{
		Username: "",
		Password: "",
	}
	c.URL = s.URL()

	return c, s
}