-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
π₯ tcp test working with CLI
- Loading branch information
Showing
17 changed files
with
522 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ | |
name: goreleaser | ||
|
||
on: | ||
pull_request: | ||
push: | ||
# run only against tags | ||
tags: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: Tests | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
tags: | ||
- '*.*.*' | ||
pull_request: | ||
branches: | ||
- '**' | ||
|
||
jobs: | ||
ci: | ||
name: Continuous Integration | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 5 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version: '>=1.22.0' | ||
- name: Run test | ||
run: go test -timeout 30s -race -count=1 ./... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,10 @@ | ||
# OpenStatus CLI | ||
|
||
OpenStatus CLI is a command line interface for OpenStatus. | ||
OpenStatus CLI is a command line interface for OpenStatus. | ||
|
||
## Installation | ||
|
||
```bash | ||
brew tap openstatus/cli | ||
brew install openstatus | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
tests: | ||
ids: | ||
- 2260 | ||
- 2264 | ||
|
||
- 1 | ||
- 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package monitors_test | ||
|
||
import ( | ||
"bytes" | ||
"io" | ||
"log" | ||
"net/http" | ||
"os" | ||
"testing" | ||
|
||
"github.com/openstatusHQ/cli/internal/monitors" | ||
) | ||
|
||
func Test_getMonitorTrigger(t *testing.T) { | ||
t.Parallel() | ||
|
||
t.Run("Monitor ID is required", func(t *testing.T) { | ||
|
||
interceptor := &interceptorHTTPClient{ | ||
f: func(req *http.Request) (*http.Response, error) { | ||
return &http.Response{ | ||
StatusCode: http.StatusOK, | ||
}, nil | ||
}, | ||
} | ||
|
||
var bf bytes.Buffer | ||
log.SetOutput(&bf) | ||
t.Cleanup(func() { | ||
log.SetOutput(os.Stdout) | ||
}) | ||
err := monitors.MonitorTrigger(interceptor.GetHTTPClient(), "", "") | ||
if err == nil { | ||
t.Errorf("Expected log output, got nothing") | ||
} | ||
}) | ||
|
||
t.Run("Successfully return", func(t *testing.T) { | ||
body := `{"resultId": 1}` | ||
r := io.NopCloser(bytes.NewReader([]byte(body))) | ||
|
||
interceptor := &interceptorHTTPClient{ | ||
f: func(req *http.Request) (*http.Response, error) { | ||
return &http.Response{ | ||
StatusCode: http.StatusOK, | ||
Body: r, | ||
}, nil | ||
}, | ||
} | ||
|
||
var bf bytes.Buffer | ||
log.SetOutput(&bf) | ||
t.Cleanup(func() { | ||
log.SetOutput(os.Stdout) | ||
}) | ||
err := monitors.MonitorTrigger(interceptor.GetHTTPClient(), "", "") | ||
if err == nil { | ||
t.Errorf("Expected log output, got nothing") | ||
} | ||
}) | ||
t.Run("No 200 throw error", func(t *testing.T) { | ||
|
||
interceptor := &interceptorHTTPClient{ | ||
f: func(req *http.Request) (*http.Response, error) { | ||
return &http.Response{ | ||
StatusCode: http.StatusInternalServerError, | ||
}, nil | ||
}, | ||
} | ||
|
||
var bf bytes.Buffer | ||
log.SetOutput(&bf) | ||
t.Cleanup(func() { | ||
log.SetOutput(os.Stdout) | ||
}) | ||
err := monitors.MonitorTrigger(interceptor.GetHTTPClient(), "1", "1") | ||
if err == nil { | ||
t.Errorf("Expected log output, got nothing") | ||
} | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.