-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(api): add create tags api route (#991)
- Loading branch information
Showing
13 changed files
with
477 additions
and
33 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
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 |
---|---|---|
|
@@ -25,6 +25,7 @@ const ( | |
LoginKey = "login" | ||
defaultContact = "testContact" | ||
defaultLogin = "testLogin" | ||
defaultTeamID = "testTeamID" | ||
) | ||
|
||
func TestGetAllContacts(t *testing.T) { | ||
|
@@ -43,7 +44,7 @@ func TestGetAllContacts(t *testing.T) { | |
ID: defaultContact, | ||
Type: "mail", | ||
Value: "[email protected]", | ||
User: "moira", | ||
User: defaultLogin, | ||
Team: "", | ||
}, | ||
}, nil).Times(1) | ||
|
@@ -55,7 +56,7 @@ func TestGetAllContacts(t *testing.T) { | |
ID: defaultContact, | ||
Type: "mail", | ||
Value: "[email protected]", | ||
User: "moira", | ||
User: defaultLogin, | ||
Team: "", | ||
}, | ||
}, | ||
|
@@ -120,7 +121,7 @@ func TestGetContactById(t *testing.T) { | |
ID: contactID, | ||
Type: "mail", | ||
Value: "[email protected]", | ||
User: "test", | ||
User: defaultLogin, | ||
Team: "", | ||
}, nil).Times(1) | ||
database = mockDb | ||
|
@@ -129,7 +130,7 @@ func TestGetContactById(t *testing.T) { | |
ID: contactID, | ||
Type: "mail", | ||
Value: "[email protected]", | ||
User: "test", | ||
User: defaultLogin, | ||
TeamID: "", | ||
} | ||
|
||
|
@@ -336,7 +337,7 @@ func TestCreateNewContact(t *testing.T) { | |
}) | ||
|
||
Convey("Trying to create a contact when both userLogin and teamID specified", func() { | ||
newContactDto.TeamID = "test" | ||
newContactDto.TeamID = defaultTeamID | ||
defer func() { | ||
newContactDto.TeamID = "" | ||
}() | ||
|
@@ -383,7 +384,7 @@ func TestUpdateContact(t *testing.T) { | |
ID: contactID, | ||
Type: "mail", | ||
Value: "[email protected]", | ||
User: "test", | ||
User: defaultLogin, | ||
TeamID: "", | ||
} | ||
|
||
|
@@ -502,7 +503,7 @@ func TestRemoveContact(t *testing.T) { | |
}) | ||
|
||
Convey("Successful deletion of a contact without team id and subscriptions", func() { | ||
mockDb.EXPECT().GetUserSubscriptionIDs("test").Return([]string{}, nil).Times(1) | ||
mockDb.EXPECT().GetUserSubscriptionIDs(defaultLogin).Return([]string{}, nil).Times(1) | ||
mockDb.EXPECT().GetSubscriptions([]string{}).Return([]*moira.SubscriptionData{}, nil).Times(1) | ||
mockDb.EXPECT().RemoveContact(contactID).Return(nil).Times(1) | ||
database = mockDb | ||
|
@@ -512,7 +513,7 @@ func TestRemoveContact(t *testing.T) { | |
ID: contactID, | ||
Type: "mail", | ||
Value: "[email protected]", | ||
User: "test", | ||
User: defaultLogin, | ||
})) | ||
testRequest.Header.Add("content-type", "application/json") | ||
|
||
|
@@ -529,7 +530,7 @@ func TestRemoveContact(t *testing.T) { | |
}) | ||
|
||
Convey("Successful deletion of a contact without user id and subscriptions", func() { | ||
mockDb.EXPECT().GetTeamSubscriptionIDs("test").Return([]string{}, nil).Times(1) | ||
mockDb.EXPECT().GetTeamSubscriptionIDs(defaultTeamID).Return([]string{}, nil).Times(1) | ||
mockDb.EXPECT().GetSubscriptions([]string{}).Return([]*moira.SubscriptionData{}, nil).Times(1) | ||
mockDb.EXPECT().RemoveContact(contactID).Return(nil).Times(1) | ||
database = mockDb | ||
|
@@ -539,7 +540,7 @@ func TestRemoveContact(t *testing.T) { | |
ID: contactID, | ||
Type: "mail", | ||
Value: "[email protected]", | ||
Team: "test", | ||
Team: defaultTeamID, | ||
})) | ||
testRequest.Header.Add("content-type", "application/json") | ||
|
||
|
@@ -556,8 +557,8 @@ func TestRemoveContact(t *testing.T) { | |
}) | ||
|
||
Convey("Successful deletion of a contact without subscriptions", func() { | ||
mockDb.EXPECT().GetUserSubscriptionIDs("test").Return([]string{}, nil).Times(1) | ||
mockDb.EXPECT().GetTeamSubscriptionIDs("test").Return([]string{}, nil).Times(1) | ||
mockDb.EXPECT().GetUserSubscriptionIDs(defaultLogin).Return([]string{}, nil).Times(1) | ||
mockDb.EXPECT().GetTeamSubscriptionIDs(defaultTeamID).Return([]string{}, nil).Times(1) | ||
mockDb.EXPECT().GetSubscriptions([]string{}).Return([]*moira.SubscriptionData{}, nil).Times(1) | ||
mockDb.EXPECT().RemoveContact(contactID).Return(nil).Times(1) | ||
database = mockDb | ||
|
@@ -567,8 +568,8 @@ func TestRemoveContact(t *testing.T) { | |
ID: contactID, | ||
Type: "mail", | ||
Value: "[email protected]", | ||
User: "test", | ||
Team: "test", | ||
User: defaultLogin, | ||
Team: defaultTeamID, | ||
})) | ||
testRequest.Header.Add("content-type", "application/json") | ||
|
||
|
@@ -590,7 +591,7 @@ func TestRemoveContact(t *testing.T) { | |
ErrorText: "this contact is being used in following subscriptions: (tags: test)", | ||
} | ||
|
||
mockDb.EXPECT().GetUserSubscriptionIDs("test").Return([]string{"test"}, nil).Times(1) | ||
mockDb.EXPECT().GetUserSubscriptionIDs(defaultLogin).Return([]string{"test"}, nil).Times(1) | ||
mockDb.EXPECT().GetSubscriptions([]string{"test"}).Return([]*moira.SubscriptionData{ | ||
{ | ||
Contacts: []string{"testContact"}, | ||
|
@@ -604,7 +605,7 @@ func TestRemoveContact(t *testing.T) { | |
ID: contactID, | ||
Type: "mail", | ||
Value: "[email protected]", | ||
User: "test", | ||
User: defaultLogin, | ||
})) | ||
testRequest.Header.Add("content-type", "application/json") | ||
|
||
|
@@ -629,7 +630,7 @@ func TestRemoveContact(t *testing.T) { | |
ErrorText: "this contact is being used in following subscriptions: (tags: test)", | ||
} | ||
|
||
mockDb.EXPECT().GetTeamSubscriptionIDs("test").Return([]string{"test"}, nil).Times(1) | ||
mockDb.EXPECT().GetTeamSubscriptionIDs(defaultTeamID).Return([]string{"test"}, nil).Times(1) | ||
mockDb.EXPECT().GetSubscriptions([]string{"test"}).Return([]*moira.SubscriptionData{ | ||
{ | ||
Contacts: []string{"testContact"}, | ||
|
@@ -643,7 +644,7 @@ func TestRemoveContact(t *testing.T) { | |
ID: contactID, | ||
Type: "mail", | ||
Value: "[email protected]", | ||
Team: "test", | ||
Team: defaultTeamID, | ||
})) | ||
testRequest.Header.Add("content-type", "application/json") | ||
|
||
|
@@ -668,8 +669,8 @@ func TestRemoveContact(t *testing.T) { | |
ErrorText: "this contact is being used in following subscriptions: (tags: test1), (tags: test2)", | ||
} | ||
|
||
mockDb.EXPECT().GetUserSubscriptionIDs("test1").Return([]string{"test1"}, nil).Times(1) | ||
mockDb.EXPECT().GetTeamSubscriptionIDs("test2").Return([]string{"test2"}, nil).Times(1) | ||
mockDb.EXPECT().GetUserSubscriptionIDs(defaultLogin).Return([]string{"test1"}, nil).Times(1) | ||
mockDb.EXPECT().GetTeamSubscriptionIDs(defaultTeamID).Return([]string{"test2"}, nil).Times(1) | ||
mockDb.EXPECT().GetSubscriptions([]string{"test1", "test2"}).Return([]*moira.SubscriptionData{ | ||
{ | ||
Contacts: []string{"testContact"}, | ||
|
@@ -687,8 +688,8 @@ func TestRemoveContact(t *testing.T) { | |
ID: contactID, | ||
Type: "mail", | ||
Value: "[email protected]", | ||
Team: "test2", | ||
User: "test1", | ||
Team: defaultTeamID, | ||
User: defaultLogin, | ||
})) | ||
testRequest.Header.Add("content-type", "application/json") | ||
|
||
|
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
Oops, something went wrong.