Skip to content

fix: use flag to enable Prometheus #12345

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
assertCallback
  • Loading branch information
mtojek committed Feb 28, 2024
commit 5e168ebf0467643c61b2a403e326c6d172dbea99
9 changes: 4 additions & 5 deletions cli/clitest/clitest.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,10 @@ func extractTar(t *testing.T, data []byte, directory string) {
// Start runs the command in a goroutine and cleans it up when the test
// completed.
func Start(t *testing.T, inv *clibase.Invocation) {
StartWithAssert(t, inv, false)
StartWithAssert(t, inv, nil)
}

func StartWithAssert(t *testing.T, inv *clibase.Invocation, errExpected bool) { //nolint:revive
func StartWithAssert(t *testing.T, inv *clibase.Invocation, assertCallback func(t *testing.T, err error)) { //nolint:revive
t.Helper()

closeCh := make(chan struct{})
Expand All @@ -160,9 +160,8 @@ func StartWithAssert(t *testing.T, inv *clibase.Invocation, errExpected bool) {
defer close(closeCh)
err := waiter.Wait()

if errExpected {
assert.Error(t, err)
assert.False(t, errors.Is(err, context.Canceled), "error was expected, but context was canceled")
if assertCallback != nil {
assertCallback(t, err)
return
}

Expand Down
6 changes: 5 additions & 1 deletion enterprise/cli/proxyserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cli_test
import (
"bufio"
"context"
"errors"
"fmt"
"net/http"
"net/http/httptest"
Expand Down Expand Up @@ -105,7 +106,10 @@ func TestWorkspaceProxy_Server_PrometheusEnabled(t *testing.T) {
defer cancel()

// Start "wsproxy server" command
clitest.StartWithAssert(t, inv, true)
clitest.StartWithAssert(t, inv, func(t *testing.T, err error) {
assert.Error(t, err)
assert.False(t, errors.Is(err, context.Canceled), "error was expected, but context was canceled")
})
pty.ExpectMatchContext(ctx, "Started HTTP listener at")

// Fetch metrics from Prometheus endpoint
Expand Down