MCPcopy
hub / github.com/gogs/gogs / actionsCommitRepo

Function actionsCommitRepo

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

Source from the content-addressed store, hash-verified

129}
130
131func actionsCommitRepo(t *testing.T, ctx context.Context, s *ActionsStore) {
132 alice, err := newUsersStore(s.db).Create(ctx, "alice", "alice@example.com", CreateUserOptions{})
133 require.NoError(t, err)
134 repo, err := newReposStore(s.db).Create(ctx,
135 alice.ID,
136 CreateRepoOptions{
137 Name: "example",
138 },
139 )
140 require.NoError(t, err)
141
142 now := time.Unix(1588568886, 0).UTC()
143
144 conf.SetMockSSH(t, conf.SSHOpts{})
145 conf.SetMockUI(t, conf.UIOpts{
146 User: conf.UIUserOpts{
147 NewsFeedPagingNum: 20,
148 },
149 })
150
151 t.Run("new commit", func(t *testing.T) {
152 t.Cleanup(func() {
153 err := s.db.Session(&gorm.Session{AllowGlobalUpdate: true}).WithContext(ctx).Delete(new(Action)).Error
154 require.NoError(t, err)
155 })
156
157 err = s.CommitRepo(ctx,
158 CommitRepoOptions{
159 PusherName: alice.Name,
160 Owner: alice,
161 Repo: repo,
162 RefFullName: "refs/heads/main",
163 OldCommitID: "ca82a6dff817ec66f44342007202690a93763949",
164 NewCommitID: "085bb3bcb608e1e8451d4b2432f8ecbe6306e7e7",
165 Commits: CommitsToPushCommits(
166 []*git.Commit{
167 {
168 ID: git.MustIDFromString("085bb3bcb608e1e8451d4b2432f8ecbe6306e7e7"),
169 Author: &git.Signature{
170 Name: "alice",
171 Email: "alice@example.com",
172 When: now,
173 },
174 Committer: &git.Signature{
175 Name: "alice",
176 Email: "alice@example.com",
177 When: now,
178 },
179 Message: "A random commit",
180 },
181 },
182 ),
183 },
184 )
185 require.NoError(t, err)
186
187 got, err := s.ListByUser(ctx, alice.ID, alice.ID, 0, false)
188 require.NoError(t, err)

Callers

nothing calls this directly

Calls 10

SetMockSSHFunction · 0.92
SetMockUIFunction · 0.92
newUsersStoreFunction · 0.85
newReposStoreFunction · 0.85
CommitsToPushCommitsFunction · 0.85
DeleteMethod · 0.80
CommitRepoMethod · 0.80
ListByUserMethod · 0.80
LenMethod · 0.65
CreateMethod · 0.45

Tested by

no test coverage detected