File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -119,3 +119,42 @@ func TestReadWritePullHead(t *testing.T) {
119
119
err = repo .RemoveReference (PullPrefix + "1/head" )
120
120
assert .NoError (t , err )
121
121
}
122
+
123
+ func TestGetCommitFilesChanged (t * testing.T ) {
124
+ bareRepo1Path := filepath .Join (testReposDir , "repo1_bare" )
125
+ clonedPath , err := cloneRepo (t , bareRepo1Path )
126
+ if err != nil {
127
+ assert .NoError (t , err )
128
+ return
129
+ }
130
+ repo , err := openRepositoryWithDefaultContext (clonedPath )
131
+ if err != nil {
132
+ assert .NoError (t , err )
133
+ return
134
+ }
135
+ defer repo .Close ()
136
+
137
+ testCases := []struct {
138
+ CommitID string
139
+ ExpectedFiles []string
140
+ }{
141
+ {
142
+ "95bb4d39648ee7e325106df01a621c530863a653" ,
143
+ []string {"file1.txt" },
144
+ },
145
+ {
146
+ "8d92fc957a4d7cfd98bc375f0b7bb189a0d6c9f2" ,
147
+ []string {"file2.txt" },
148
+ },
149
+ }
150
+
151
+ for _ , tc := range testCases {
152
+ id , err := repo .ConvertToSHA1 (tc .CommitID )
153
+ assert .NoError (t , err )
154
+ commit , err := repo .getCommit (id )
155
+ assert .NoError (t , err )
156
+ changedFiles , err := repo .GetCommitFilesChanged (commit )
157
+ assert .NoError (t , err )
158
+ assert .ElementsMatch (t , changedFiles , tc .ExpectedFiles )
159
+ }
160
+ }
You can’t perform that action at this time.
0 commit comments