Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

chore: spin clock library out to coder/quartz repo#13777

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
spikecurtis merged 2 commits intomainfromspike/clock-testing-quartz
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes fromall commits
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
6 changes: 3 additions & 3 deletionsagent/apphealth.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,9 +10,9 @@ import (
"golang.org/x/xerrors"

"cdr.dev/slog"
"github.com/coder/coder/v2/clock"
"github.com/coder/coder/v2/codersdk"
"github.com/coder/coder/v2/codersdk/agentsdk"
"github.com/coder/quartz"
)

// PostWorkspaceAgentAppHealth updates the workspace app health.
Expand All@@ -23,7 +23,7 @@ type WorkspaceAppHealthReporter func(ctx context.Context)

// NewWorkspaceAppHealthReporter creates a WorkspaceAppHealthReporter that reports app health to coderd.
func NewWorkspaceAppHealthReporter(logger slog.Logger, apps []codersdk.WorkspaceApp, postWorkspaceAgentAppHealth PostWorkspaceAgentAppHealth) WorkspaceAppHealthReporter {
return NewAppHealthReporterWithClock(logger, apps, postWorkspaceAgentAppHealth,clock.NewReal())
return NewAppHealthReporterWithClock(logger, apps, postWorkspaceAgentAppHealth,quartz.NewReal())
}

// NewAppHealthReporterWithClock is only called directly by test code. Product code should call
Expand All@@ -32,7 +32,7 @@ func NewAppHealthReporterWithClock(
logger slog.Logger,
apps []codersdk.WorkspaceApp,
postWorkspaceAgentAppHealth PostWorkspaceAgentAppHealth,
clkclock.Clock,
clkquartz.Clock,
) WorkspaceAppHealthReporter {
logger = logger.Named("apphealth")

Expand Down
10 changes: 5 additions & 5 deletionsagent/apphealth_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,11 +17,11 @@ import (
"github.com/coder/coder/v2/agent"
"github.com/coder/coder/v2/agent/agenttest"
"github.com/coder/coder/v2/agent/proto"
"github.com/coder/coder/v2/clock"
"github.com/coder/coder/v2/coderd/httpapi"
"github.com/coder/coder/v2/codersdk"
"github.com/coder/coder/v2/codersdk/agentsdk"
"github.com/coder/coder/v2/testutil"
"github.com/coder/quartz"
)

func TestAppHealth_Healthy(t *testing.T) {
Expand DownExpand Up@@ -69,7 +69,7 @@ func TestAppHealth_Healthy(t *testing.T) {
httpapi.Write(r.Context(), w, http.StatusOK, nil)
}),
}
mClock :=clock.NewMock(t)
mClock :=quartz.NewMock(t)
healthcheckTrap := mClock.Trap().TickerFunc("healthcheck")
defer healthcheckTrap.Close()
reportTrap := mClock.Trap().TickerFunc("report")
Expand DownExpand Up@@ -137,7 +137,7 @@ func TestAppHealth_500(t *testing.T) {
}),
}

mClock :=clock.NewMock(t)
mClock :=quartz.NewMock(t)
healthcheckTrap := mClock.Trap().TickerFunc("healthcheck")
defer healthcheckTrap.Close()
reportTrap := mClock.Trap().TickerFunc("report")
Expand DownExpand Up@@ -187,7 +187,7 @@ func TestAppHealth_Timeout(t *testing.T) {
<-r.Context().Done()
}),
}
mClock :=clock.NewMock(t)
mClock :=quartz.NewMock(t)
start := mClock.Now()

// for this test, it's easier to think in the number of milliseconds elapsed
Expand DownExpand Up@@ -235,7 +235,7 @@ func setupAppReporter(
ctx context.Context, t *testing.T,
apps []codersdk.WorkspaceApp,
handlers []http.Handler,
clkclock.Clock,
clkquartz.Clock,
) (*agenttest.FakeAgentAPI, func()) {
closers := []func(){}
for _, app := range apps {
Expand Down
Loading
Loading

[8]ページ先頭

©2009-2025 Movatter.jp