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

Function TestPauseNotifications_RegularUser

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

Source from the content-addressed store, hash-verified

81}
82
83func TestPauseNotifications_RegularUser(t *testing.T) {
84 t.Parallel()
85
86 // given
87 ownerClient, db := coderdtest.NewWithDatabase(t, createOpts(t))
88 owner := coderdtest.CreateFirstUser(t, ownerClient)
89 anotherClient, _ := coderdtest.CreateAnotherUser(t, ownerClient, owner.OrganizationID)
90
91 // when
92 inv, root := clitest.New(t, "notifications", "pause")
93 clitest.SetupConfig(t, anotherClient, root)
94
95 var buf bytes.Buffer
96 inv.Stdout = &buf
97 err := inv.Run()
98 var sdkError *codersdk.Error
99 require.Error(t, err)
100 require.ErrorAsf(t, err, &sdkError, "error should be of type *codersdk.Error")
101 assert.Equal(t, http.StatusForbidden, sdkError.StatusCode())
102 assert.Contains(t, sdkError.Message, "Forbidden.")
103
104 // then
105 ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort)
106 t.Cleanup(cancel)
107 settingsJSON, err := db.GetNotificationsSettings(ctx)
108 require.NoError(t, err)
109
110 var settings codersdk.NotificationsSettings
111 err = json.Unmarshal([]byte(settingsJSON), &settings)
112 require.NoError(t, err)
113 require.False(t, settings.NotifierPaused) // still running
114}
115
116func TestNotificationsTest(t *testing.T) {
117 t.Parallel()

Callers

nothing calls this directly

Calls 14

StatusCodeMethod · 0.95
NewWithDatabaseFunction · 0.92
CreateFirstUserFunction · 0.92
CreateAnotherUserFunction · 0.92
NewFunction · 0.92
SetupConfigFunction · 0.92
createOptsFunction · 0.70
RunMethod · 0.65
CleanupMethod · 0.65
ErrorMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected