/
GoferOperationTest.class.st
225 lines (200 loc) · 5.29 KB
/
GoferOperationTest.class.st
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
"
SUnit tests for Gofer operations
"
Class {
#name : #GoferOperationTest,
#superclass : #GoferTest,
#instVars : [
'environment'
],
#category : #'Gofer-Tests-Tests'
}
{ #category : #utilities }
GoferOperationTest >> allManagers [
^ MCWorkingCopy allManagers
]
{ #category : #accessing }
GoferOperationTest >> environment [
^ environment
]
{ #category : #accessing }
GoferOperationTest >> environment: anObject [
environment := anObject
]
{ #category : #utilities }
GoferOperationTest >> hasClass: aSymbol [
^ environment includesKey: aSymbol
]
{ #category : #utilities }
GoferOperationTest >> hasClass: aSymbol selector: aSelector [
^ (environment classNamed: aSymbol) includesSelector: aSelector
]
{ #category : #utilities }
GoferOperationTest >> hasPackage: aString [
^ self allManagers anySatisfy: [ :package | package packageName = aString ]
]
{ #category : #utilities }
GoferOperationTest >> hasVersion: aString [
^ self allManagers anySatisfy: [ :version | version ancestry ancestorString = aString ]
]
{ #category : #running }
GoferOperationTest >> setUp [
super setUp.
self setUpEnvironment.
gofer repository: self monticelloRepository
]
{ #category : #running }
GoferOperationTest >> setUpEnvironment [
environment := self class environment.
]
{ #category : #running }
GoferOperationTest >> tearDown [
(self hasPackage: 'GoferFoo')
ifTrue: [ Gofer new package: 'GoferFoo'; unload ].
(self hasPackage: 'GoferBar')
ifTrue: [ Gofer new package: 'GoferBar'; unload ].
(self hasPackage: 'ConfigurationOfGoferFoo')
ifTrue: [ Gofer new package: 'ConfigurationOfGoferFoo'; unload ].
super tearDown.
]
{ #category : #tests }
GoferOperationTest >> testCleanup [
| class |
gofer
package: 'GoferFoo';
load.
class := environment classNamed: #GoferFoo.
environment organization addCategory: #'GoferFoo-Empty'.
class organization addCategory: #empty.
class class organization addCategory: #empty.
gofer cleanup.
self deny: (Smalltalk organization categories includes: #'GoferFoo-Empty').
self deny: (class organization categories includes: #'GoferFoo-Empty').
self deny: (class class organization categories includes: #'GoferFoo-Empty')
]
{ #category : #tests }
GoferOperationTest >> testCommit [
| repository |
repository := MCDictionaryRepository new.
gofer
package: 'GoferFoo';
load.
gofer := Gofer new.
gofer
disablePackageCache;
repository: repository;
package: 'GoferFoo';
commit: 'A test commit'.
self assert: repository allVersionInfos size equals: 1
]
{ #category : #tests }
GoferOperationTest >> testFetch [
gofer package: 'GoferFoo'.
gofer fetch
]
{ #category : #tests }
GoferOperationTest >> testLoad [
gofer version: 'GoferFoo-lr.1'.
gofer load.
self assert: (self hasVersion: 'GoferFoo-lr.1').
self assert: (self hasClass: #GoferFoo)
]
{ #category : #tests }
GoferOperationTest >> testLocalChanges [
| changes |
gofer
package: 'GoferBar';
load.
(environment classNamed: #GoferBar) compile: 'foo'.
changes := gofer localChanges.
self assert: changes operations size equals: 1
]
{ #category : #tests }
GoferOperationTest >> testMerge [
| initial |
initial := gofer copy.
initial
version: 'GoferBar-jf.1';
load.
gofer
package: 'GoferBar';
load.
(environment classNamed: #GoferBar) compile: 'foo'.
[ gofer merge ]
on: ProvideAnswerNotification
do: [ :e | e resume: true ].
self assert: (self hasClass: #GoferBar selector: #foo)
]
{ #category : #tests }
GoferOperationTest >> testPush [
| repository |
gofer := Gofer new.
gofer disablePackageCache.
gofer repository: (repository := MCDictionaryRepository new).
gofer package: 'GoferFoo'.
gofer push
]
{ #category : #tests }
GoferOperationTest >> testRecompile [
gofer package: 'Gofer-Core'.
gofer recompile
]
{ #category : #tests }
GoferOperationTest >> testReinitialize [
| class |
gofer
package: 'GoferFoo';
load.
class := Smalltalk classNamed: #GoferFoo.
class
addClassVarNamed: #InstanceSide;
addClassVarNamed: #ClassSide.
class compile: 'initialize InstanceSide := true'.
class class compile: 'initialize ClassSide := true'.
self assert: (class classPool at: #InstanceSide) isNil.
self assert: (class classPool at: #ClassSide) isNil.
gofer reinitialize.
self assert: (class classPool at: #InstanceSide) isNil.
self assert: (class classPool at: #ClassSide)
]
{ #category : #tests }
GoferOperationTest >> testRemoteChanges [
| changes |
gofer
package: 'GoferBar';
load.
(environment classNamed: #GoferBar) compile: 'foo'.
changes := gofer remoteChanges.
self assert: changes operations size equals: 1
]
{ #category : #tests }
GoferOperationTest >> testRevert [
gofer
package: 'GoferFoo';
package: 'GoferBar';
load.
(environment classNamed: #GoferBar) category: 'GoferFoo'.
gofer revert.
self assert: (environment classNamed: #GoferFoo) category asSymbol equals: #GoferFoo.
self assert: (environment classNamed: #GoferBar) category asSymbol equals: #GoferBar
]
{ #category : #tests }
GoferOperationTest >> testUnload [
gofer
package: 'GoferFoo';
load.
gofer unload.
self deny: (self hasPackage: 'GoferFoo').
self deny: (self hasClass: #GoferFoo)
]
{ #category : #tests }
GoferOperationTest >> testUpdate [
| initial |
initial := gofer copy.
initial
version: 'GoferFoo-lr.1';
load.
gofer package: 'GoferFoo'.
gofer update.
self assert: (self hasVersion: 'GoferFoo-lr.4')
]