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

Function TestNotifications

cli/notifications_test.go:32–81  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

30}
31
32func TestNotifications(t *testing.T) {
33 t.Parallel()
34
35 tests := []struct {
36 name string
37 command string
38 expectPaused bool
39 }{
40 {
41 name: "PauseNotifications",
42 command: "pause",
43 expectPaused: true,
44 },
45 {
46 name: "ResumeNotifications",
47 command: "resume",
48 expectPaused: false,
49 },
50 }
51
52 for _, tt := range tests {
53 t.Run(tt.name, func(t *testing.T) {
54 t.Parallel()
55
56 // given
57 ownerClient, db := coderdtest.NewWithDatabase(t, createOpts(t))
58 _ = coderdtest.CreateFirstUser(t, ownerClient)
59
60 // when
61 inv, root := clitest.New(t, "notifications", tt.command)
62 clitest.SetupConfig(t, ownerClient, root)
63
64 var buf bytes.Buffer
65 inv.Stdout = &buf
66 err := inv.Run()
67 require.NoError(t, err)
68
69 // then
70 ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort)
71 t.Cleanup(cancel)
72 settingsJSON, err := db.GetNotificationsSettings(ctx)
73 require.NoError(t, err)
74
75 var settings codersdk.NotificationsSettings
76 err = json.Unmarshal([]byte(settingsJSON), &settings)
77 require.NoError(t, err)
78 require.Equal(t, tt.expectPaused, settings.NotifierPaused)
79 })
80 }
81}
82
83func TestPauseNotifications_RegularUser(t *testing.T) {
84 t.Parallel()

Callers

nothing calls this directly

Calls 10

NewWithDatabaseFunction · 0.92
CreateFirstUserFunction · 0.92
NewFunction · 0.92
SetupConfigFunction · 0.92
createOptsFunction · 0.70
RunMethod · 0.65
CleanupMethod · 0.65
UnmarshalMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected