2
0
mirror of https://github.com/VinylDNS/vinyldns synced 2025-08-31 14:25:30 +00:00

added unit tests

This commit is contained in:
Jay07GIT
2024-01-17 12:40:07 +05:30
parent 0589596f4d
commit 9903b86db0

View File

@@ -1402,5 +1402,21 @@ class MembershipServiceSpec
error shouldBe a[UserNotFoundError]
}
}
"get user info" should {
"return the user info" in {
doReturn(IO.pure(Some(okUser))).when(mockUserRepo).getUserByIdOrName(anyString)
doReturn(IO.pure(Set(okGroup.id))).when(mockMembershipRepo).getGroupsForUser(anyString)
val result: UserResponseInfo = underTest.getUserDetails(okUser.id, okAuth).value.unsafeRunSync().toOption.get
result.id shouldBe okUser.id
result.userName.get shouldBe okUser.userName
result.groupId shouldBe Set(okGroup.id)
}
"return an error if the user is not found" in {
doReturn(IO.pure(None)).when(mockUserRepo).getUserByIdOrName(anyString)
val error = underTest.getUserDetails("notfound", okAuth).value.unsafeRunSync().swap.toOption.get
error shouldBe a[UserNotFoundError]
}
}
}
}