forked from pharo-project/pharo
/
MetacelloRepositorySqueakCommonTestCase.class.st
233 lines (211 loc) · 8.07 KB
/
MetacelloRepositorySqueakCommonTestCase.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
226
227
228
229
230
231
232
233
Class {
#name : #MetacelloRepositorySqueakCommonTestCase,
#superclass : #TestCase,
#category : #'Metacello-TestsPlatform'
}
{ #category : #baselines }
MetacelloRepositorySqueakCommonTestCase >> baseline10: spec [
<version: '1.0-baseline'>
spec
for: #'common'
do: [
spec
package: 'Example-Core'
with: [
spec
includes: 'Example-AddOn';
file: 'Example-Core-anon.1';
repository: self directoryForPlatform ] ]
]
{ #category : #baselines }
MetacelloRepositorySqueakCommonTestCase >> baseline13: spec [
<version: '1.3-baseline'>
spec
for: #'squeakCommon'
do: [
spec
package: 'Example-Core'
with: [
spec
includes: 'Example-AddOn';
file: 'Example-Core-anon.1';
repository: 'ftp://ftp.example.com/examples' ] ]
]
{ #category : #baselines }
MetacelloRepositorySqueakCommonTestCase >> baseline14: spec [
<version: '1.4-baseline'>
spec
for: #'common'
do: [
spec
package: 'Example-Core'
with: [
spec
includes: 'Example-AddOn';
file: 'Example-Core-anon.1';
repository: 'http://example.com/examples' ] ]
]
{ #category : #baselines }
MetacelloRepositorySqueakCommonTestCase >> baseline15: spec [
<version: '1.5-baseline'>
spec
for: #'common'
do: [
spec
package: 'Example-Core'
with: [
spec
includes: 'Example-AddOn';
file: 'Example-Core-anon.1';
repository: 'dictionary://Metacello_Platform_Test_GlobalDictionary' ] ]
]
{ #category : #baselines }
MetacelloRepositorySqueakCommonTestCase >> baseline16: spec [
<version: '1.6-baseline'>
spec
for: #'common'
do: [
spec
package: 'Example-Core'
with: [
spec
includes: 'Example-AddOn';
file: 'Example-Core-anon.1';
repository:
'filetree://' , MCFileTreeFileUtils current default fullName , '/temp/repo' ] ]
]
{ #category : #accessing }
MetacelloRepositorySqueakCommonTestCase >> directoryForPlatform [
| dir |
"I don't know how to do this in other platforms (not Pharo)"
dir := '/opt/mcexamples'.
(Smalltalk classNamed: #OSPlatform) ifNotNil: [ :c |
c current isWindows
ifTrue: [ dir := 'c:\opt\mcexamples' ] ].
^ dir
]
{ #category : #accessing }
MetacelloRepositorySqueakCommonTestCase >> project [
"force new version as workaround for https://code.google.com/p/smalltalk-hub/issues/detail?id=21"
| constructor project |
"Construct Metacello project"
constructor := MetacelloVersionConstructor on: self.
project := constructor project.
project loader: MetacelloNullRecordingMCSpecLoader new.
^project
]
{ #category : #running }
MetacelloRepositorySqueakCommonTestCase >> setUp [
super setUp.
aTestEnvironment
at: #'Metacello_Platform_Test_GlobalDictionary'
put:
(MCDictionaryRepository new
description: 'dictionary://Metacello_Platform_Test_GlobalDictionary';
yourself)
]
{ #category : #running }
MetacelloRepositorySqueakCommonTestCase >> tearDown [
aTestEnvironment removeKey: #'Metacello_Platform_Test_GlobalDictionary' ifAbsent: [ ].
super tearDown
]
{ #category : #tests }
MetacelloRepositorySqueakCommonTestCase >> testAsRepositorySpecFor [
| project testBlock |
project := self project.
testBlock := [ :pkg :expectedType1 :expectedType2 |
| repoSpec1 repo repoSpec2 |
repoSpec1 := pkg repositorySpecs first.
self assert: repoSpec1 type = expectedType1.
repo := repoSpec1 createRepository.
repoSpec2 := repo asRepositorySpecFor: project.
self assert: repoSpec2 type = expectedType2.
expectedType1 = expectedType2
ifTrue: [ self assert: repoSpec1 description = repoSpec2 description ]
ifFalse: [
"special case for standard directory type that defaults to MCServerDirectoryRepository"
self
assert:
(repoSpec1 description copyFrom: 'server://' size + 1 to: repoSpec1 description size) = repoSpec2 description ] ].
testBlock
value: ((project version: '1.0-baseline') packageNamed: 'Example-Core')
value: 'directory'
value: 'directory'.
testBlock value: ((project version: '1.3-baseline') packageNamed: 'Example-Core') value: 'ftp' value: 'ftp'.
testBlock value: ((project version: '1.4-baseline') packageNamed: 'Example-Core') value: 'http' value: 'http'.
testBlock
value: ((project version: '1.5-baseline') packageNamed: 'Example-Core')
value: 'dictionary'
value: 'dictionary'
]
{ #category : #tests }
MetacelloRepositorySqueakCommonTestCase >> testDictionaryRepository [
| project pkg repoSpec repo |
project := self project.
pkg := (project version: '1.5-baseline') packageNamed: 'Example-Core'.
repoSpec := pkg repositorySpecs first.
self assert: repoSpec type = 'dictionary'.
repo := repoSpec createRepository.
self assert: repo class == MCDictionaryRepository.
self assert: repo dictionary == (aTestEnvironment at: #'Metacello_Platform_Test_GlobalDictionary') dictionary
]
{ #category : #tests }
MetacelloRepositorySqueakCommonTestCase >> testDirectoryRepository [
| project pkg repoSpec repo |
project := self project.
pkg := (project version: '1.0-baseline') packageNamed: 'Example-Core'.
repoSpec := pkg repositorySpecs first.
self assert: repoSpec type = 'directory'.
repo := repoSpec createRepository.
self assert: repo class == MCDirectoryRepository.
self assert: repo description = self directoryForPlatform
]
{ #category : #tests }
MetacelloRepositorySqueakCommonTestCase >> testFileTreeRepository [
"must create repository against an existing directory"
| project pkg repoSpec repo fileUtils workingDir tempDir repoDir |
fileUtils := MCFileTreeFileUtils current.
workingDir := fileUtils default.
tempDir := fileUtils directoryFromPath: 'temp' relativeTo: workingDir.
[
fileUtils ensureDirectoryExists: tempDir.
repoDir := fileUtils directoryFromPath: 'repo' relativeTo: tempDir.
fileUtils ensureDirectoryExists: repoDir.
project := self project.
pkg := (project version: '1.6-baseline') packageNamed: 'Example-Core'.
repoSpec := pkg repositorySpecs first.
self assert: repoSpec type = 'filetree'.
repo := repoSpec createRepository.
self
assert: repo class == (aTestEnvironment at: #'MCFileTreeRepository' ifAbsent: [ ]).
Transcript cr; show: 'testFileTreeRepository: ', (fileUtils directoryFromPath: 'temp/repo' relativeTo: fileUtils default) fullName.
self
assert:
repo description = ('filetree://' , (fileUtils directoryFromPath: 'temp/repo' relativeTo: fileUtils default) fullName )]
ensure: [
(fileUtils directoryExists: tempDir)
ifTrue: [ fileUtils deleteAll: tempDir ] ]
]
{ #category : #tests }
MetacelloRepositorySqueakCommonTestCase >> testFtpRepository [
| project pkg repoSpec repo |
project := self project.
pkg := (project version: '1.3-baseline') packageNamed: 'Example-Core'.
repoSpec := pkg repositorySpecs first.
self assert: repoSpec type = 'ftp'.
repo := repoSpec createRepository.
self assert: repo class == MCFtpRepository.
self assert: repo host = 'ftp.example.com'.
self assert: repo directory = 'examples'
]
{ #category : #tests }
MetacelloRepositorySqueakCommonTestCase >> testHttpRepository [
| project pkg repoSpec repo |
project := self project.
pkg := (project version: '1.4-baseline') packageNamed: 'Example-Core'.
repoSpec := pkg repositorySpecs first.
self assert: repoSpec type = 'http'.
repo := repoSpec createRepository.
self assert: repo class == MCHttpRepository.
self assert: repo description = 'http://example.com/examples'
]