-
Notifications
You must be signed in to change notification settings - Fork 75
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
Get Blob support #494
Get Blob support #494
Conversation
val gh = clientResource.map { client => | ||
Github[IO](client, accessToken) | ||
} | ||
|
||
val response: GHResponse[NonEmptyList[Content]] = gh | ||
.use( | ||
_.repos.getContents(validRepoOwner, validRepoName, validFilePath, headers = headerUserAgent) | ||
) | ||
.unsafeRunSync() | ||
|
||
val fileContentO = for { | ||
res <- response.result.toOption | ||
content <- res.head.content | ||
} yield content | ||
|
||
fileContentO.isDefined shouldBe true | ||
|
||
val blobResponse = for { | ||
res <- response.result.toOption | ||
} yield gh.use( | ||
_.gitData.getBlob(validRepoOwner, validRepoName, res.head.sha, headers = headerUserAgent) | ||
) | ||
|
||
blobResponse.isDefined shouldBe true | ||
|
||
val responseBlob = blobResponse.get.unsafeRunSync() | ||
|
||
testIsRight[BlobContent](responseBlob, r => r.content shouldBe fileContentO) | ||
response.statusCode shouldBe okStatusCode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can be simplified a bit: https://gist.github.com/BenFradet/4d5e85580ef986d7c39300d5690af867
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about this approach?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup that's cool too 👍
Co-authored-by: Ben Fradet <benjamin.fradet@gmail.com>
Co-authored-by: Ben Fradet <benjamin.fradet@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks 👍
No description provided.