@@ -205,41 +205,42 @@ func TestDirsSinglePath(t *testing.T) {
205
205
}
206
206
}
207
207
208
- /* more data for tests
209
-
210
- directories.go:169: WEIRD cloud.google.com/go/iam/admin/apiv1
211
- map[cloud.google.com/go:1 cloud.google.com/go/iam:5]:
212
- [cloud.google.com/go/[email protected] /admin/apiv1
213
- cloud.google.com/go/[email protected] /admin/apiv1
214
- cloud.google.com/go/[email protected] /admin/apiv1
215
- cloud.google.com/go/[email protected] /admin/apiv1
216
- cloud.google.com/go/[email protected] /admin/apiv1
217
- cloud.google.com/[email protected] /iam/admin/apiv1]
218
- directories.go:169: WEIRD cloud.google.com/go/iam
219
- map[cloud.google.com/go:1 cloud.google.com/go/iam:5]:
220
- [cloud.google.com/go/[email protected] cloud.google.com/go/[email protected]
221
- cloud.google.com/go/[email protected] cloud.google.com/go/[email protected]
222
- cloud.google.com/go/[email protected] cloud.google.com/[email protected] /iam]
223
- directories.go:169: WEIRD cloud.google.com/go/compute/apiv1
224
- map[cloud.google.com/go:1 cloud.google.com/go/compute:4]:
225
- [cloud.google.com/go/[email protected] /apiv1
226
- cloud.google.com/go/[email protected] /apiv1
227
- cloud.google.com/go/[email protected] /apiv1
228
- cloud.google.com/go/[email protected] /apiv1
229
- cloud.google.com/[email protected] /compute/apiv1]
230
- directories.go:169: WEIRD cloud.google.com/go/longrunning/autogen
231
- map[cloud.google.com/go:2 cloud.google.com/go/longrunning:2]:
232
- [cloud.google.com/go/[email protected] /autogen
233
- cloud.google.com/go/[email protected] /autogen
234
- cloud.google.com/[email protected] /longrunning/autogen
235
- cloud.google.com/[email protected] /longrunning/autogen]
236
- directories.go:169: WEIRD cloud.google.com/go/iam/credentials/apiv1
237
- map[cloud.google.com/go:1 cloud.google.com/go/iam:5]:
238
- [cloud.google.com/go/[email protected] /credentials/apiv1
239
- cloud.google.com/go/[email protected] /credentials/apiv1
240
- cloud.google.com/go/[email protected] /credentials/apiv1
241
- cloud.google.com/go/[email protected] /credentials/apiv1
242
- cloud.google.com/go/[email protected] /credentials/apiv1
243
- cloud.google.com/[email protected] /iam/credentials/apiv1]
208
+ func TestMissingCachedir (t * testing.T ) {
209
+ // behave properly if the cached dir is empty
210
+ dir := testModCache (t )
211
+ if err := Create (dir ); err != nil {
212
+ t .Fatal (err )
213
+ }
214
+ ixd , err := IndexDir ()
215
+ if err != nil {
216
+ t .Fatal (err )
217
+ }
218
+ des , err := os .ReadDir (ixd )
219
+ if err != nil {
220
+ t .Fatal (err )
221
+ }
222
+ if len (des ) != 2 {
223
+ t .Errorf ("got %d, butexpected two entries in index dir" , len (des ))
224
+ }
225
+ }
244
226
245
- */
227
+ func TestMissingIndex (t * testing.T ) {
228
+ // behave properly if there is no existing index
229
+ dir := testModCache (t )
230
+ if ok , err := Update (dir ); err != nil {
231
+ t .Fatal (err )
232
+ } else if ! ok {
233
+ t .Error ("Update returned !ok" )
234
+ }
235
+ ixd , err := IndexDir ()
236
+ if err != nil {
237
+ t .Fatal (err )
238
+ }
239
+ des , err := os .ReadDir (ixd )
240
+ if err != nil {
241
+ t .Fatal (err )
242
+ }
243
+ if len (des ) != 2 {
244
+ t .Errorf ("got %d, butexpected two entries in index dir" , len (des ))
245
+ }
246
+ }
0 commit comments