|
16 | 16 |
|
17 | 17 | package github4s.integration |
18 | 18 |
|
19 | | -import cats.effect.IO |
20 | 19 | import cats.data.NonEmptyList |
| 20 | +import cats.effect.{IO, Resource} |
21 | 21 | import github4s.GHError.NotFoundError |
22 | 22 | import github4s.Github |
23 | 23 | import github4s.domain._ |
@@ -133,6 +133,44 @@ trait ReposSpec extends BaseIntegrationSpec { |
133 | 133 | response.statusCode shouldBe okStatusCode |
134 | 134 | } |
135 | 135 |
|
| 136 | + "Repos >> GetContents" should "have the same contents with getBlob using fileSha" taggedAs Integration in { |
| 137 | + |
| 138 | + val blobResponseFileContent = for { |
| 139 | + client <- clientResource |
| 140 | + res = Github[IO](client, accessToken) |
| 141 | + |
| 142 | + fileContentsIO = res.repos.getContents( |
| 143 | + owner = validRepoOwner, |
| 144 | + repo = validRepoName, |
| 145 | + path = validFilePath, |
| 146 | + headers = headerUserAgent |
| 147 | + ) |
| 148 | + |
| 149 | + fileContentsResponse <- Resource.liftF(fileContentsIO) |
| 150 | + |
| 151 | + fileContentsEither = fileContentsResponse.result |
| 152 | + |
| 153 | + fileContents <- Resource.liftF(IO.fromEither(fileContentsEither)) |
| 154 | + |
| 155 | + blobContentIO = res.gitData.getBlob( |
| 156 | + owner = validRepoOwner, |
| 157 | + repo = validRepoName, |
| 158 | + fileSha = fileContents.head.sha, |
| 159 | + headers = headerUserAgent |
| 160 | + ) |
| 161 | + |
| 162 | + blobContentResponse <- Resource.liftF(blobContentIO) |
| 163 | + |
| 164 | + } yield (blobContentResponse, fileContents.head) |
| 165 | + |
| 166 | + val (blobContentResponse, fileContent) = blobResponseFileContent |
| 167 | + .use(a => IO.apply(a)) |
| 168 | + .unsafeRunSync() |
| 169 | + |
| 170 | + testIsRight[BlobContent](blobContentResponse, _.content.shouldBe(fileContent.content)) |
| 171 | + blobContentResponse.statusCode shouldBe okStatusCode |
| 172 | + } |
| 173 | + |
136 | 174 | it should "return error when an invalid path is passed" taggedAs Integration in { |
137 | 175 | val response = clientResource |
138 | 176 | .use { client => |
|
0 commit comments