Skip to content

Commit

Permalink
squash: use SimpleHTTP in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ThinkChaos committed Aug 28, 2024
1 parent 282c75c commit dfceae4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 17 deletions.
21 changes: 5 additions & 16 deletions service/http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var _ = Describe("Service HTTP", func() {
Describe("HTTPInfo", func() {
It("returns the expected router", func() {
endpoints := EndpointsFromAddrs("proto", []string{":1", "localhost:2"})
sut := HTTPInfo{Info{"name", endpoints}, chi.NewMux()}
sut := NewHTTPInfo("name", endpoints)

Expect(sut.ServiceName()).Should(Equal("name"))
Expect(sut.ExposeOn()).Should(Equal(endpoints))
Expand Down Expand Up @@ -105,20 +105,9 @@ var _ = Describe("Service HTTP", func() {
})
})

type fakeHTTPService struct {
HTTPInfo
}

func newFakeHTTPService(name string, addrs ...string) *fakeHTTPService {
mux := chi.NewMux()
mux.Get("/"+name, nil)

return &fakeHTTPService{HTTPInfo{
Info: Info{Name: name, Endpoints: EndpointsFromAddrs("http", addrs)},
Mux: mux,
}}
}
func newFakeHTTPService(name string, addrs ...string) HTTPService {
svc := NewSimpleHTTP(name, EndpointsFromAddrs("http", addrs))
svc.Router().Get("/"+name, nil)

func (s *fakeHTTPService) Merge(other Service) (Merger, error) {
return MergeHTTP(s, other)
return &svc
}
2 changes: 1 addition & 1 deletion service/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var _ = Describe("Service", func() {

Describe("Info", func() {
endpoints := EndpointsFromAddrs("proto", []string{":1", "localhost:2"})
sut := Info{"name", endpoints}
sut := NewInfo("name", endpoints)

It("implements Service", func() {
var svc Service = &sut
Expand Down

0 comments on commit dfceae4

Please sign in to comment.