Repository navigation
Expand file tree
/
Copy pathGTDiffDeltaSpec.m
More file actions
82 lines (66 loc) · 2.51 KB
/
Copy pathGTDiffDeltaSpec.m
File metadata and controls
82 lines (66 loc) · 2.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
//
// GTDiffDeltaSpec.m
// ObjectiveGitFramework
//
// Created by Josh Abernathy on 7/15/14.
// Copyright (c) 2014 GitHub, Inc. All rights reserved.
//
#import <Nimble/Nimble.h>
#import <ObjectiveGit/ObjectiveGit.h>
#import <Quick/Quick.h>
#import "QuickSpec+GTFixtures.h"
QuickSpecBegin(GTDiffDeltaSpec)
__block GTRepository *repository;
__block GTDiffDelta *delta;
beforeEach(^{
repository = [self testAppFixtureRepository];
});
describe(@"blob-to-blob diffing", ^{
beforeEach(^{
GTBlob *blob1 = [repository lookUpObjectBySHA:@"847cd4b33f4e33bc413468bab016303b50d26d95" error:NULL];
expect(blob1).notTo(beNil());
GTBlob *blob2 = [repository lookUpObjectBySHA:@"6060bdeee91b02cb56d9826b4208e9b34122f3f1" error:NULL];
expect(blob2).notTo(beNil());
delta = [GTDiffDelta diffDeltaFromBlob:blob1 forPath:@"README1.txt" toBlob:blob2 forPath:@"README1.txt" options:nil error:NULL];
expect(delta).notTo(beNil());
});
it(@"should generate a patch", ^{
GTDiffPatch *patch = [delta generatePatch:NULL];
expect(patch).notTo(beNil());
expect(@(patch.hunkCount)).to(equal(@1));
expect(@(patch.addedLinesCount)).to(equal(@1));
expect(@(patch.deletedLinesCount)).to(equal(@1));
});
});
describe(@"blob-to-data diffing", ^{
beforeEach(^{
GTBlob *blob = [repository lookUpObjectBySHA:@"847cd4b33f4e33bc413468bab016303b50d26d95" error:NULL];
expect(blob).notTo(beNil());
NSData *data = [@"hello, world" dataUsingEncoding:NSUTF8StringEncoding];
delta = [GTDiffDelta diffDeltaFromBlob:blob forPath:@"README" toData:data forPath:@"README" options:nil error:NULL];
expect(delta).notTo(beNil());
});
it(@"should generate a patch", ^{
GTDiffPatch *patch = [delta generatePatch:NULL];
expect(patch).notTo(beNil());
expect(@(patch.hunkCount)).to(equal(@1));
expect(@(patch.addedLinesCount)).to(equal(@1));
expect(@(patch.deletedLinesCount)).to(equal(@26));
});
});
describe(@"data-to-data diffing", ^{
beforeEach(^{
NSData *data1 = [@"hello world!\nwhat's up" dataUsingEncoding:NSUTF8StringEncoding];
NSData *data2 = [@"hello, world" dataUsingEncoding:NSUTF8StringEncoding];
delta = [GTDiffDelta diffDeltaFromData:data1 forPath:@"README" toData:data2 forPath:@"README" options:nil error:NULL];
expect(delta).notTo(beNil());
});
it(@"should generate a patch", ^{
GTDiffPatch *patch = [delta generatePatch:NULL];
expect(patch).notTo(beNil());
expect(@(patch.hunkCount)).to(equal(@1));
expect(@(patch.addedLinesCount)).to(equal(@1));
expect(@(patch.deletedLinesCount)).to(equal(@2));
});
});
QuickSpecEnd