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

Function TestServer

cli/server_test.go:194–1831  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

192}
193
194func TestServer(t *testing.T) {
195 t.Parallel()
196
197 t.Run("BuiltinPostgres", func(t *testing.T) {
198 t.Parallel()
199 if testing.Short() {
200 t.SkipNow()
201 }
202
203 inv, cfg := clitest.New(t,
204 "server",
205 "--http-address", ":0",
206 "--access-url", "http://example.com",
207 "--cache-dir", t.TempDir(),
208 )
209
210 const superDuperLong = testutil.WaitSuperLong * 3
211 ctx := testutil.Context(t, superDuperLong)
212 clitest.Start(t, inv.WithContext(ctx))
213
214 //nolint:gocritic // Embedded postgres take a while to fire up.
215 require.Eventually(t, func() bool {
216 rawURL, err := cfg.URL().Read()
217 return err == nil && rawURL != ""
218 }, superDuperLong, testutil.IntervalFast, "failed to get access URL")
219 })
220 t.Run("EphemeralDeployment", func(t *testing.T) {
221 t.Parallel()
222 if testing.Short() {
223 t.SkipNow()
224 }
225
226 inv, _ := clitest.New(t,
227 "server",
228 "--http-address", ":0",
229 "--access-url", "http://example.com",
230 "--ephemeral",
231 )
232 pty := ptytest.New(t).Attach(inv)
233
234 // Embedded postgres takes a while to fire up.
235 const superDuperLong = testutil.WaitSuperLong * 3
236 ctx, cancelFunc := context.WithCancel(testutil.Context(t, superDuperLong))
237 errCh := make(chan error, 1)
238 go func() {
239 errCh <- inv.WithContext(ctx).Run()
240 }()
241 matchCh1 := make(chan string, 1)
242 go func() {
243 matchCh1 <- pty.ExpectMatchContext(ctx, "Using an ephemeral deployment directory")
244 }()
245 select {
246 case err := <-errCh:
247 require.NoError(t, err)
248 case <-matchCh1:
249 // OK!
250 }
251 rootDirLine := pty.ReadLine(ctx)

Callers

nothing calls this directly

Calls 15

AuthMethodsMethod · 0.95
HasFirstUserMethod · 0.95
RequestMethod · 0.95
CreateFirstUserMethod · 0.95
LoginWithPasswordMethod · 0.95
SetSessionTokenMethod · 0.95
DeploymentConfigMethod · 0.95
NewFunction · 0.92
ContextFunction · 0.92
StartFunction · 0.92
NewFunction · 0.92
OpenFunction · 0.92

Tested by

no test coverage detected