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

Function TestManager_UnitValidation

agent/unit/manager_test.go:19–48  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

17)
18
19func TestManager_UnitValidation(t *testing.T) {
20 t.Parallel()
21
22 t.Run("Empty Unit Name", func(t *testing.T) {
23 t.Parallel()
24
25 manager := unit.NewManager()
26
27 err := manager.Register("")
28 require.ErrorIs(t, err, unit.ErrUnitIDRequired)
29 err = manager.AddDependency("", unitA, unit.StatusStarted)
30 require.ErrorIs(t, err, unit.ErrUnitIDRequired)
31 err = manager.AddDependency(unitA, "", unit.StatusStarted)
32 require.ErrorIs(t, err, unit.ErrUnitIDRequired)
33 dependencies, err := manager.GetAllDependencies("")
34 require.ErrorIs(t, err, unit.ErrUnitIDRequired)
35 require.Len(t, dependencies, 0)
36 unmetDependencies, err := manager.GetUnmetDependencies("")
37 require.ErrorIs(t, err, unit.ErrUnitIDRequired)
38 require.Len(t, unmetDependencies, 0)
39 err = manager.UpdateStatus("", unit.StatusStarted)
40 require.ErrorIs(t, err, unit.ErrUnitIDRequired)
41 isReady, err := manager.IsReady("")
42 require.ErrorIs(t, err, unit.ErrUnitIDRequired)
43 require.False(t, isReady)
44 u, err := manager.Unit("")
45 require.ErrorIs(t, err, unit.ErrUnitIDRequired)
46 assert.Equal(t, unit.Unit{}, u)
47 })
48}
49
50func TestManager_Register(t *testing.T) {
51 t.Parallel()

Callers

nothing calls this directly

Calls 11

RegisterMethod · 0.95
AddDependencyMethod · 0.95
GetAllDependenciesMethod · 0.95
GetUnmetDependenciesMethod · 0.95
UpdateStatusMethod · 0.95
IsReadyMethod · 0.95
UnitMethod · 0.95
NewManagerFunction · 0.92
RunMethod · 0.65
LenMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected