mirror of
https://github.com/coder/coder.git
synced 2026-06-02 20:48:20 +00:00
refactor: convert workspacesdk.AgentConn to an interface (#19392)
Fixes https://github.com/coder/internal/issues/907 We convert `workspacesdk.AgentConn` to an interface and generate a mock for it. This allows writing `coderd` tests that rely on the agent's HTTP api to not have to set up an entire tailnet networking stack.
This commit is contained in:
+2
-2
@@ -390,7 +390,7 @@ func connectedAgentInfo(ctx context.Context, client *codersdk.Client, log slog.L
|
||||
if err := conn.Close(); err != nil {
|
||||
log.Error(ctx, "failed to close agent connection", slog.Error(err))
|
||||
}
|
||||
<-conn.Closed()
|
||||
<-conn.TailnetConn().Closed()
|
||||
}
|
||||
|
||||
eg.Go(func() error {
|
||||
@@ -399,7 +399,7 @@ func connectedAgentInfo(ctx context.Context, client *codersdk.Client, log slog.L
|
||||
return xerrors.Errorf("create request: %w", err)
|
||||
}
|
||||
rr := httptest.NewRecorder()
|
||||
conn.MagicsockServeHTTPDebug(rr, req)
|
||||
conn.TailnetConn().MagicsockServeHTTPDebug(rr, req)
|
||||
a.ClientMagicsockHTML = rr.Body.Bytes()
|
||||
return nil
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user