| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package archivist | 5 package archivist |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "fmt" | 8 "fmt" |
| 9 "strings" | 9 "strings" |
| 10 "sync" | 10 "sync" |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 sc := testServicesClient{ | 290 sc := testServicesClient{ |
| 291 lsCallback: func(req *logdog.LoadStreamRequest) (*logdog
.LoadStreamResponse, error) { | 291 lsCallback: func(req *logdog.LoadStreamRequest) (*logdog
.LoadStreamResponse, error) { |
| 292 return &stream, nil | 292 return &stream, nil |
| 293 }, | 293 }, |
| 294 asCallback: func(req *logdog.ArchiveStreamRequest) error
{ | 294 asCallback: func(req *logdog.ArchiveStreamRequest) error
{ |
| 295 archiveRequest = req | 295 archiveRequest = req |
| 296 return archiveStreamErr | 296 return archiveStreamErr |
| 297 }, | 297 }, |
| 298 } | 298 } |
| 299 | 299 |
| 300 stBase := Settings{} |
| 301 |
| 300 ar := Archivist{ | 302 ar := Archivist{ |
| 301 » » » Service: &sc, | 303 » » » Service: &sc, |
| 302 » » » Storage: &st, | 304 » » » SettingsLoader: func(c context.Context, proj config.Proj
ectName) (*Settings, error) { |
| 303 » » » GSClient: &gsc, | 305 » » » » if proj == "" { |
| 304 » » » GSBase: gs.Path("gs://archive-test/path/to/archiv
e/"), // Extra slashes to test concatenation. | 306 » » » » » proj = "_" |
| 305 » » » GSStagingBase: gs.Path("gs://archive-test-staging/path/t
o/archive/"), // Extra slashes to test concatenation. | 307 » » » » } |
| 308 |
| 309 » » » » // Extra slashes to test concatenation,. |
| 310 » » » » st := stBase |
| 311 » » » » st.GSBase = gs.Path(fmt.Sprintf("gs://archival/%
s/path/to/archive/", proj)) |
| 312 » » » » st.GSStagingBase = gs.Path(fmt.Sprintf("gs://arc
hival-staging/%s/path/to/archive/", proj)) |
| 313 » » » » return &st, nil |
| 314 » » » }, |
| 315 » » » Storage: &st, |
| 316 » » » GSClient: &gsc, |
| 306 } | 317 } |
| 307 | 318 |
| 308 gsURL := func(project, name string) string { | 319 gsURL := func(project, name string) string { |
| 309 » » » return fmt.Sprintf("gs://archive-test/path/to/archive/%s
/%s/%s", project, desc.Path(), name) | 320 » » » if project == "" { |
| 321 » » » » project = "_" |
| 322 » » » } |
| 323 |
| 324 » » » return fmt.Sprintf("gs://archival/%s/path/to/archive/%s/
%s/%s", project, project, desc.Path(), name) |
| 310 } | 325 } |
| 311 | 326 |
| 312 // hasStreams can be called to check that the retained archiveRe
quest had | 327 // hasStreams can be called to check that the retained archiveRe
quest had |
| 313 // data sizes for the named archive stream types. | 328 // data sizes for the named archive stream types. |
| 314 // | 329 // |
| 315 // After checking, the values are set to zero. This allows us to
use | 330 // After checking, the values are set to zero. This allows us to
use |
| 316 // ShouldEqual without hardcoding specific archival sizes into t
he results. | 331 // ShouldEqual without hardcoding specific archival sizes into t
he results. |
| 317 hasStreams := func(log, index, data bool) bool { | 332 hasStreams := func(log, index, data bool) bool { |
| 318 So(archiveRequest, ShouldNotBeNil) | 333 So(archiveRequest, ShouldNotBeNil) |
| 319 if (log && archiveRequest.StreamSize <= 0) || | 334 if (log && archiveRequest.StreamSize <= 0) || |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 650 | 665 |
| 651 So(ar.archiveTaskImpl(c, task),
ShouldErrLike, "test error") | 666 So(ar.archiveTaskImpl(c, task),
ShouldErrLike, "test error") |
| 652 So(task.consumed, ShouldBeFalse) | 667 So(task.consumed, ShouldBeFalse) |
| 653 So(archiveRequest, ShouldBeNil) | 668 So(archiveRequest, ShouldBeNil) |
| 654 }) | 669 }) |
| 655 } | 670 } |
| 656 } | 671 } |
| 657 }) | 672 }) |
| 658 }) | 673 }) |
| 659 } | 674 } |
| OLD | NEW |