(t *testing.T, ctx context.Context, s *ActionsStore)
| 734 | } |
| 735 | |
| 736 | func actionsPushTag(t *testing.T, ctx context.Context, s *ActionsStore) { |
| 737 | // NOTE: We set a noop mock here to avoid data race with other tests that writes |
| 738 | // to the mock server because this function holds a lock. |
| 739 | conf.SetMockServer(t, conf.ServerOpts{}) |
| 740 | conf.SetMockSSH(t, conf.SSHOpts{}) |
| 741 | conf.SetMockUI(t, conf.UIOpts{ |
| 742 | User: conf.UIUserOpts{ |
| 743 | NewsFeedPagingNum: 20, |
| 744 | }, |
| 745 | }) |
| 746 | |
| 747 | alice, err := newUsersStore(s.db).Create(ctx, "alice", "alice@example.com", CreateUserOptions{}) |
| 748 | require.NoError(t, err) |
| 749 | repo, err := newReposStore(s.db).Create(ctx, |
| 750 | alice.ID, |
| 751 | CreateRepoOptions{ |
| 752 | Name: "example", |
| 753 | }, |
| 754 | ) |
| 755 | require.NoError(t, err) |
| 756 | |
| 757 | t.Run("new tag", func(t *testing.T) { |
| 758 | t.Cleanup(func() { |
| 759 | err := s.db.Session(&gorm.Session{AllowGlobalUpdate: true}).WithContext(ctx).Delete(new(Action)).Error |
| 760 | require.NoError(t, err) |
| 761 | }) |
| 762 | |
| 763 | err = s.PushTag(ctx, |
| 764 | PushTagOptions{ |
| 765 | Owner: alice, |
| 766 | Repo: repo, |
| 767 | PusherName: alice.Name, |
| 768 | RefFullName: "refs/tags/v1.0.0", |
| 769 | NewCommitID: "085bb3bcb608e1e8451d4b2432f8ecbe6306e7e7", |
| 770 | }, |
| 771 | ) |
| 772 | require.NoError(t, err) |
| 773 | |
| 774 | got, err := s.ListByUser(ctx, alice.ID, alice.ID, 0, false) |
| 775 | require.NoError(t, err) |
| 776 | require.Len(t, got, 1) |
| 777 | got[0].ID = 0 |
| 778 | |
| 779 | want := []*Action{ |
| 780 | { |
| 781 | UserID: alice.ID, |
| 782 | OpType: ActionPushTag, |
| 783 | ActUserID: alice.ID, |
| 784 | ActUserName: alice.Name, |
| 785 | RepoID: repo.ID, |
| 786 | RepoUserName: alice.Name, |
| 787 | RepoName: repo.Name, |
| 788 | RefName: "v1.0.0", |
| 789 | IsPrivate: false, |
| 790 | CreatedUnix: s.db.NowFunc().Unix(), |
| 791 | }, |
| 792 | } |
| 793 | want[0].Created = time.Unix(want[0].CreatedUnix, 0) |
nothing calls this directly
no test coverage detected