-
-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathfetch.spec.js
72 lines (52 loc) · 2.35 KB
/
fetch.spec.js
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
import { lgPromise } from './common.js';
import assert from 'assert';
describe('git fetch', () => {
it('should create 1 bare and 2 clones and fetch changes', async () => {
const lg = await lgPromise;
const FS = lg.FS;
FS.mkdir('bare');
FS.chdir('bare');
lg.callMain(['init', '--bare', '.']);
lg.callMain(['config', 'user.name', 'The Tester']);
lg.callMain(['config', 'user.email', '[email protected]']);
FS.chdir('..');
lg.callMain(['clone', 'bare', 'test1']);
FS.chdir('test1');
lg.callMain(['config', 'user.name', 'The Tester']);
lg.callMain(['config', 'user.email', '[email protected]']);
FS.writeFile('test.txt', 'abcdef');
lg.callMain(['add', 'test.txt']);
lg.callMain(['commit', '-m', 'test commit 1']);
lg.callMain(['push']);
FS.chdir('..');
lg.callMain(['clone', 'bare', 'test2']);
FS.chdir('test2');
lg.callMain(['config', 'user.name', 'The Tester']);
lg.callMain(['config', 'user.email', '[email protected]']);
FS.writeFile('test2.txt', 'abcdef');
lg.callMain(['add', 'test2.txt']);
lg.callMain(['commit', '-m', 'test commit 2']);
lg.callMain(['push']);
lg.callMain(['log']);
FS.chdir('..');
FS.chdir('test1');
lg.callMain(['fetch', 'origin']);
lg.callMain(['merge', 'origin/master']);
const result = lg.callWithOutput(['log']);
assert.ok(result.indexOf('test commit 2') > 0);
assert.ok(result.indexOf('test commit 1') > result.indexOf('test commit 2') > 0);
lg.callMain(['checkout', '-b', 'testbranch']);
FS.writeFile('testinbranch.txt', 'abcdef');
lg.callMain(['add', 'testinbranch.txt']);
lg.callMain(['commit', '-m', 'test in branch']);
lg.callMain(['push']);
FS.chdir('..');
FS.chdir('test2');
assert.equal(FS.analyzePath('testinbranch.txt').exists, false);
lg.callMain(['fetch', 'origin']);
lg.callMain(['checkout', 'testbranch']);
assert.match(lg.callWithOutput(['status']), /On branch testbranch/);
assert.equal(FS.analyzePath('testinbranch.txt').exists, true);
assert.equal(FS.readFile('testinbranch.txt', {encoding: 'utf8'}), 'abcdef');
});
});