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

Function TestSyncCommands_Golden

cli/sync_test.go:50–412  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

48}
49
50func TestSyncCommands_Golden(t *testing.T) {
51 t.Parallel()
52
53 t.Run("ping", func(t *testing.T) {
54 t.Parallel()
55 path, cleanup := setupSocketServer(t)
56 defer cleanup()
57
58 ctx := testutil.Context(t, testutil.WaitShort)
59
60 var outBuf bytes.Buffer
61 inv, _ := clitest.New(t, "exp", "sync", "ping", "--socket-path", path)
62 inv.Stdout = &outBuf
63 inv.Stderr = &outBuf
64
65 err := inv.WithContext(ctx).Run()
66 require.NoError(t, err)
67
68 clitest.TestGoldenFile(t, "TestSyncCommands_Golden/ping_success", outBuf.Bytes(), nil)
69 })
70
71 t.Run("start_no_dependencies", func(t *testing.T) {
72 t.Parallel()
73 path, cleanup := setupSocketServer(t)
74 defer cleanup()
75
76 ctx := testutil.Context(t, testutil.WaitShort)
77
78 var outBuf bytes.Buffer
79 inv, _ := clitest.New(t, "exp", "sync", "start", "test-unit", "--socket-path", path)
80 inv.Stdout = &outBuf
81 inv.Stderr = &outBuf
82
83 err := inv.WithContext(ctx).Run()
84 require.NoError(t, err)
85
86 clitest.TestGoldenFile(t, "TestSyncCommands_Golden/start_no_dependencies", outBuf.Bytes(), nil)
87 })
88
89 t.Run("start_with_dependencies", func(t *testing.T) {
90 t.Parallel()
91 path, cleanup := setupSocketServer(t)
92 defer cleanup()
93
94 ctx := testutil.Context(t, testutil.WaitShort)
95
96 // Set up dependencies: test-unit depends on dep-unit and dep-unit-2.
97 client, err := agentsocket.NewClient(ctx, agentsocket.WithPath(path))
98 require.NoError(t, err)
99
100 err = client.SyncWant(ctx, "test-unit", "dep-unit")
101 require.NoError(t, err)
102 err = client.SyncWant(ctx, "test-unit", "dep-unit-2")
103 require.NoError(t, err)
104 client.Close()
105
106 outBuf := testutil.NewWaitBuffer()
107 done := make(chan error, 1)

Callers

nothing calls this directly

Calls 15

SyncWantMethod · 0.95
CloseMethod · 0.95
SyncStartMethod · 0.95
SyncCompleteMethod · 0.95
ContextFunction · 0.92
NewFunction · 0.92
TestGoldenFileFunction · 0.92
NewClientFunction · 0.92
WithPathFunction · 0.92
NewWaitBufferFunction · 0.92
setupSocketServerFunction · 0.85
cleanupFunction · 0.85

Tested by

no test coverage detected