MCPcopy Create free account
hub / github.com/antonmedv/gitmal / TestParseTraditionalFileHeader

Function TestParseTraditionalFileHeader

pkg/gitdiff/file_header_test.go:172–275  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

170}
171
172func TestParseTraditionalFileHeader(t *testing.T) {
173 tests := map[string]struct {
174 Input string
175 Output *File
176 Err bool
177 }{
178 "fileContentChange": {
179 Input: `--- dir/file_old.txt 2019-03-21 23:00:00.0 -0700
180+++ dir/file_new.txt 2019-03-21 23:30:00.0 -0700
181@@ -0,0 +1 @@
182`,
183 Output: &File{
184 OldName: "dir/file_new.txt",
185 NewName: "dir/file_new.txt",
186 },
187 },
188 "newFile": {
189 Input: `--- /dev/null 1969-12-31 17:00:00.0 -0700
190+++ dir/file.txt 2019-03-21 23:30:00.0 -0700
191@@ -0,0 +1 @@
192`,
193 Output: &File{
194 NewName: "dir/file.txt",
195 IsNew: true,
196 },
197 },
198 "newFileTimestamp": {
199 Input: `--- dir/file.txt 1969-12-31 17:00:00.0 -0700
200+++ dir/file.txt 2019-03-21 23:30:00.0 -0700
201@@ -0,0 +1 @@
202`,
203 Output: &File{
204 NewName: "dir/file.txt",
205 IsNew: true,
206 },
207 },
208 "deleteFile": {
209 Input: `--- dir/file.txt 2019-03-21 23:30:00.0 -0700
210+++ /dev/null 1969-12-31 17:00:00.0 -0700
211@@ -0,0 +1 @@
212`,
213 Output: &File{
214 OldName: "dir/file.txt",
215 IsDelete: true,
216 },
217 },
218 "deleteFileTimestamp": {
219 Input: `--- dir/file.txt 2019-03-21 23:30:00.0 -0700
220+++ dir/file.txt 1969-12-31 17:00:00.0 -0700
221@@ -0,0 +1 @@
222`,
223 Output: &File{
224 OldName: "dir/file.txt",
225 IsDelete: true,
226 },
227 },
228 "useShortestPrefixName": {
229 Input: `--- dir/file.txt 2019-03-21 23:00:00.0 -0700

Callers

nothing calls this directly

Calls 3

newTestParserFunction · 0.85
ErrorfMethod · 0.80

Tested by

no test coverage detected