Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List followers of a user #810

Open
abteilung6 opened this issue Jul 31, 2022 · 3 comments
Open

List followers of a user #810

abteilung6 opened this issue Jul 31, 2022 · 3 comments

Comments

@abteilung6
Copy link

Users.scala

  /**
   * Lists the people following the specified user.
   *
   * @param username of the user to retrieve
   * @param pagination Limit and Offset for pagination
   * @param headers optional user headers to include in the request
   * @return GHResponse[List[User]\] User details
   */
  def getFollowers(
      username: String,
      pagination: Option[Pagination] = None,
      headers: Map[String, String] = Map()
  ): F[GHResponse[List[User]]]

UsersInterpreter.scala

  override def getFollowers(
      username: String,
      pagination: Option[Pagination],
      headers: Map[String, String]
  ): F[GHResponse[List[User]]] =
    client
      .get[List[User]](s"users/$username/followers", headers, pagination = pagination)

UsersSpec.scala

  "Users >> GetFollowers" should "return the expected followers list for a valid username" taggedAs Integration in {
    val response = clientResource
      .use { client =>
        Github[IO](client, accessToken).users
          .getFollowers(validUsername, None, headerUserAgent)
      }
      .unsafeRunSync()

    testIsRight[List[User]](response, r => r.nonEmpty shouldBe true)
    response.statusCode shouldBe okStatusCode
  }

  it should "return error on Left for invalid username" taggedAs Integration in {
    val response = clientResource
      .use { client =>
        Github[IO](client, accessToken).users
          .getFollowers(invalidUsername, None, headerUserAgent)
      }
      .unsafeRunSync()

    testIsLeft[GHError.NotFoundError, List[User]](response)
    response.statusCode shouldBe notFoundStatusCode
  }
@fedefernandez
Copy link
Contributor

@abteilung6, thanks for the suggestions. I can help you with the missing pieces if you want to create the PR. It would be nice to give you the proper credits for the contribution.

@abteilung6
Copy link
Author

@fedefernandez I think i didn't had the permission for an upstream branch in order to create a draft PR.
But I will retry it the next days!

@fedefernandez
Copy link
Contributor

@abteilung6 yeah, I think the only way would be through a fork

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants