|
4 | 4 | "context" |
5 | 5 | "fmt" |
6 | 6 | "net/http" |
| 7 | + "time" |
7 | 8 |
|
8 | 9 | "github.com/jiaozifs/jiaozifs/api" |
9 | 10 | apiimpl "github.com/jiaozifs/jiaozifs/api/api_impl" |
@@ -394,6 +395,45 @@ func RepoSpec(ctx context.Context, urlStr string) func(c convey.C) { |
394 | 395 | convey.So(*result.JSON200, convey.ShouldHaveLength, 1) |
395 | 396 | convey.So((*result.JSON200)[0].Message, convey.ShouldEqual, "first commit") |
396 | 397 | }) |
| 398 | + |
| 399 | + uploadObject(ctx, c, client, "add sec object", userName, repoName, controller.DefaultBranchName, "b.txt") |
| 400 | + commitWip(ctx, c, client, "commit sec object", userName, repoName, controller.DefaultBranchName, "second commit") |
| 401 | + uploadObject(ctx, c, client, "add third object", userName, repoName, controller.DefaultBranchName, "c.txt") |
| 402 | + commitWip(ctx, c, client, "commit third object", userName, repoName, controller.DefaultBranchName, "third commit") |
| 403 | + c.Convey("success get commits by params", func() { |
| 404 | + resp, err := client.GetCommitsInRepository(ctx, userName, repoName, &api.GetCommitsInRepositoryParams{ |
| 405 | + RefName: utils.String(controller.DefaultBranchName), |
| 406 | + }) |
| 407 | + convey.So(err, convey.ShouldBeNil) |
| 408 | + convey.So(resp.StatusCode, convey.ShouldEqual, http.StatusOK) |
| 409 | + |
| 410 | + result, err := api.ParseGetCommitsInRepositoryResponse(resp) |
| 411 | + convey.So(err, convey.ShouldBeNil) |
| 412 | + convey.So(*result.JSON200, convey.ShouldHaveLength, 3) |
| 413 | + convey.So((*result.JSON200)[0].Message, convey.ShouldEqual, "third commit") |
| 414 | + |
| 415 | + newResp, err := client.GetCommitsInRepository(ctx, userName, repoName, &api.GetCommitsInRepositoryParams{ |
| 416 | + After: utils.String((*result.JSON200)[0].Committer.When.Format(time.RFC3339Nano)), |
| 417 | + Amount: utils.Int(1), |
| 418 | + RefName: utils.String(controller.DefaultBranchName), |
| 419 | + }) |
| 420 | + convey.So(err, convey.ShouldBeNil) |
| 421 | + convey.So(resp.StatusCode, convey.ShouldEqual, http.StatusOK) |
| 422 | + |
| 423 | + newResult, err := api.ParseGetCommitsInRepositoryResponse(newResp) |
| 424 | + convey.So(err, convey.ShouldBeNil) |
| 425 | + convey.So(*newResult.JSON200, convey.ShouldHaveLength, 1) |
| 426 | + convey.So((*newResult.JSON200)[0].Message, convey.ShouldEqual, "second commit") |
| 427 | + }) |
| 428 | + |
| 429 | + c.Convey("failed get commits by wrong params", func() { |
| 430 | + resp, err := client.GetCommitsInRepository(ctx, userName, repoName, &api.GetCommitsInRepositoryParams{ |
| 431 | + After: utils.String("123"), |
| 432 | + RefName: utils.String(controller.DefaultBranchName), |
| 433 | + }) |
| 434 | + convey.So(err, convey.ShouldBeNil) |
| 435 | + convey.So(resp.StatusCode, convey.ShouldEqual, http.StatusInternalServerError) |
| 436 | + }) |
397 | 437 | }) |
398 | 438 |
|
399 | 439 | c.Convey("delete repository", func(c convey.C) { |
|
0 commit comments