(t *testing.T)
| 212 | } |
| 213 | |
| 214 | func 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 |
nothing calls this directly
no test coverage detected
searching dependent graphs…