forked from raystack/guardian
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: use pointer for workspace in slack cache item
- Loading branch information
Showing
2 changed files
with
43 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -125,6 +125,41 @@ func (s *ClientTestSuite) TestParseMessage() { | |
}) | ||
} | ||
|
||
func (s *ClientTestSuite) TestGetSlackWorkspaceForUser() { | ||
s.setup() | ||
s.Run("should return slack workspace 1 for user", func() { | ||
userEmail := "[email protected]" | ||
expectedWs := &slack.SlackWorkspace{ | ||
WorkspaceName: "ws-1", | ||
AccessToken: "XXXXX-TOKEN-1-XXXXX", | ||
Criteria: "$email contains '@abc'", | ||
} | ||
actualWs, err := s.notifier.GetSlackWorkspaceForUser(userEmail) | ||
s.Nil(err) | ||
s.Equal(expectedWs, actualWs) | ||
}) | ||
|
||
s.Run("should return slack workspace 2 for user", func() { | ||
userEmail := "[email protected]" | ||
expectedWs := &slack.SlackWorkspace{ | ||
WorkspaceName: "ws-2", | ||
AccessToken: "XXXXX-TOKEN-2-XXXXX", | ||
Criteria: "$email contains '@xyz'", | ||
} | ||
actualWs, err := s.notifier.GetSlackWorkspaceForUser(userEmail) | ||
s.Nil(err) | ||
s.Equal(expectedWs, actualWs) | ||
}) | ||
|
||
s.Run("should return error if slack workspace not found for user", func() { | ||
userEmail := "[email protected]" | ||
expectedErr := fmt.Errorf("no slack workspace found for user: %s", userEmail) | ||
_, actualErr := s.notifier.GetSlackWorkspaceForUser(userEmail) | ||
s.Equal(expectedErr, actualErr) | ||
}) | ||
|
||
} | ||
|
||
func TestClient(t *testing.T) { | ||
suite.Run(t, new(ClientTestSuite)) | ||
} |