MCPcopy Create free account
hub / github.com/libgit2/git2go / TestRebaseGpgSigned

Function TestRebaseGpgSigned

rebase_test.go:214–292  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

212}
213
214func TestRebaseGpgSigned(t *testing.T) {
215 // TEST DATA
216
217 entity, err := openpgp.NewEntity("Namey mcnameface", "test comment", "test@example.com", nil)
218 checkFatal(t, err)
219
220 rebaseOpts, err := DefaultRebaseOptions()
221 checkFatal(t, err)
222
223 signCommitContent := func(commitContent string) (string, string, error) {
224 cipherText := new(bytes.Buffer)
225 err := openpgp.ArmoredDetachSignText(cipherText, entity, strings.NewReader(commitContent), &packet.Config{})
226 if err != nil {
227 return "", "", errors.New("error signing payload")
228 }
229
230 return cipherText.String(), "", nil
231 }
232 rebaseOpts.CommitSigningCallback = signCommitContent
233
234 commitOpts := commitOptions{
235 CommitSigningCallback: signCommitContent,
236 }
237
238 // Inputs
239 branchName := "emile"
240 masterCommit := "something"
241 emileCommits := []string{
242 "fou",
243 "barre",
244 "ouich",
245 }
246
247 // Outputs
248 expectedHistory := []string{
249 "Test rebase, Baby! " + emileCommits[2],
250 "Test rebase, Baby! " + emileCommits[1],
251 "Test rebase, Baby! " + emileCommits[0],
252 "Test rebase, Baby! " + masterCommit,
253 "This is a commit\n",
254 }
255
256 // TEST
257 repo := createTestRepo(t)
258 defer cleanupTestRepo(t, repo)
259 seedTestRepoOpt(t, repo, commitOpts)
260
261 // Try to open existing rebase
262 _, err = repo.OpenRebase(nil)
263 if err == nil {
264 t.Fatal("Did not expect to find a rebase in progress")
265 }
266
267 // Setup a repo with 2 branches and a different tree
268 err = setupRepoForRebase(repo, masterCommit, branchName, commitOpts)
269 checkFatal(t, err)
270
271 // Create several commits in emile

Callers

nothing calls this directly

Calls 15

checkFatalFunction · 0.85
DefaultRebaseOptionsFunction · 0.85
createTestRepoFunction · 0.85
cleanupTestRepoFunction · 0.85
seedTestRepoOptFunction · 0.85
setupRepoForRebaseFunction · 0.85
commitSomethingFunction · 0.85
performRebaseOntoFunction · 0.85
commitMsgsListFunction · 0.85
assertStringListFunction · 0.85
checkAllCommitsSignedFunction · 0.85
OpenRebaseMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…