MCPcopy Create free account
hub / github.com/gogs/gogs / actionsPushTag

Function actionsPushTag

internal/database/actions_test.go:736–836  ·  view source on GitHub ↗
(t *testing.T, ctx context.Context, s *ActionsStore)

Source from the content-addressed store, hash-verified

734}
735
736func 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)

Callers

nothing calls this directly

Calls 10

SetMockServerFunction · 0.92
SetMockSSHFunction · 0.92
SetMockUIFunction · 0.92
newUsersStoreFunction · 0.85
newReposStoreFunction · 0.85
DeleteMethod · 0.80
PushTagMethod · 0.80
ListByUserMethod · 0.80
LenMethod · 0.65
CreateMethod · 0.45

Tested by

no test coverage detected