Skip to content

Commit

Permalink
add api docs for occam matchers
Browse files Browse the repository at this point in the history
  • Loading branch information
Frankie Gallina-Jones authored and sophiewigmore committed Jan 31, 2022
1 parent a2f9231 commit 7efd2cc
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions matchers/be_available.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"github.com/paketo-buildpacks/occam"
)

// BeAvailable matches if the actual occam.Container is running AND an
// HTTP request to at least one of its exposed ports completes without error.
func BeAvailable() types.GomegaMatcher {
return &BeAvailableMatcher{
Docker: occam.NewDocker(),
Expand Down
4 changes: 4 additions & 0 deletions matchers/contain_lines.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ import (
"github.com/onsi/gomega/types"
)

// ContainLines matches if all of the 'expected' matchers match with lines
// (i.e. newline-delimited substrings) in the 'actual' string or fmt.Stringer.
// Matching lines must appear in the order that the 'expected' matchers are
// passed.
func ContainLines(expected ...interface{}) types.GomegaMatcher {
return &containLinesMatcher{
expected: expected,
Expand Down
9 changes: 9 additions & 0 deletions matchers/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import (
"github.com/paketo-buildpacks/occam"
)

// Serve matches if the actual occam.Container is running AND the
// response from an HTTP request to the container's exposed port
// matches the 'expected' matcher passed as an argument.
func Serve(expected interface{}) *ServeMatcher {
return &ServeMatcher{
expected: expected,
Expand All @@ -26,16 +29,22 @@ type ServeMatcher struct {
response string
}

// OnPort sets the container port that is expected to be exposed.
func (sm *ServeMatcher) OnPort(port int) *ServeMatcher {
sm.port = port
return sm
}

// WithEndpoint sets the endpoint or subdirectory where the expected content
// should be available. For example, WithEndpoint("/health") will attempt to
// access the server's /health endpoint.
func (sm *ServeMatcher) WithEndpoint(endpoint string) *ServeMatcher {
sm.endpoint = endpoint
return sm
}

// WithDocker sets the occam.Docker that the matcher will use to access
// the 'actual' container's metadata.
func (sm *ServeMatcher) WithDocker(docker occam.Docker) *ServeMatcher {
sm.docker = docker
return sm
Expand Down

0 comments on commit 7efd2cc

Please sign in to comment.