MCPcopy Create free account
hub / github.com/bluekeyes/patch2pr / runPatchTest

Function runPatchTest

applier_test.go:73–105  ·  view source on GitHub ↗
(t *testing.T, tctx *TestContext, name string)

Source from the content-addressed store, hash-verified

71}
72
73func runPatchTest(t *testing.T, tctx *TestContext, name string) {
74 f, err := os.Open(filepath.Join("testdata", "patches", name+".patch"))
75 if err != nil {
76 t.Fatalf("error opening patch file: %v", err)
77 }
78 defer f.Close()
79
80 files, _, err := gitdiff.Parse(f)
81 if err != nil {
82 t.Fatalf("error parsing patch: %v", err)
83 }
84
85 applier := NewApplier(tctx.Client, tctx.Repo, tctx.BaseCommit)
86 for _, file := range files {
87 if _, err := applier.Apply(tctx, file); err != nil {
88 t.Fatalf("error applying file patch: %s: %v", file.NewName, err)
89 }
90 }
91
92 commit, err := applier.Commit(tctx, nil, &gitdiff.PatchHeader{
93 Title: name,
94 })
95 if err != nil {
96 t.Fatalf("error committing changes: %v", err)
97 }
98
99 ref := NewReference(tctx.Client, tctx.Repo, tctx.Branch(name))
100 if err := ref.Set(tctx, commit.GetSHA(), true); err != nil {
101 t.Fatalf("error creating ref: %v", err)
102 }
103
104 assertPatchResult(t, tctx, name, commit)
105}
106
107type treeFile struct {
108 Mode string

Callers 1

TestApplierFunction · 0.85

Calls 7

ApplyMethod · 0.95
CommitMethod · 0.95
SetMethod · 0.95
NewApplierFunction · 0.85
NewReferenceFunction · 0.85
assertPatchResultFunction · 0.85
BranchMethod · 0.80

Tested by

no test coverage detected