MCPcopy Index your code
hub / github.com/coder/coder / newHarness

Function newHarness

coderd/workspaceconnwatcher/watcher_test.go:49–68  ·  view source on GitHub ↗
(ctx context.Context, t *testing.T, logger slog.Logger)

Source from the content-addressed store, hash-verified

47}
48
49func newHarness(ctx context.Context, t *testing.T, logger slog.Logger) *harness {
50 h := &harness{
51 workspace: database.Workspace{
52 ID: workspaceID,
53 OrganizationID: orgID,
54 OwnerID: userID,
55 },
56 orgID: orgID,
57 userID: userID,
58 logger: logger,
59 }
60 ps := pubsub.NewInMemory()
61 h.pub = ps
62
63 var authzDB database.Store
64 _, h.db, authzDB, _ = coderdtest.MockedDatabaseWithAuthz(t, logger)
65 h.watcher = workspaceconnwatcher.New(ctx, logger.Named("watcher"), ps, authzDB)
66 t.Cleanup(h.watcher.Close)
67 return h
68}
69
70func (h *harness) Dial(ctx context.Context, url string) (*wsjson.Decoder[workspacesdk.ConnectionWatchEvent], error) {
71 rt := testutil.InMemWebsocketRoundTripper{

Callers 5

TestWatcher_AgentsFunction · 0.85
TestWatcher_LostAccessFunction · 0.85

Calls 5

NewInMemoryFunction · 0.92
MockedDatabaseWithAuthzFunction · 0.92
NewFunction · 0.92
NamedMethod · 0.80
CleanupMethod · 0.65

Tested by

no test coverage detected