Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(328)

Side by Side Diff: environs/tools_test.go

Issue 6485044: environs: tweaks to ListTools interface
Patch Set: environs: tweaks to ListTools interface Created 12 years, 7 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « environs/tools.go ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 package environs_test 1 package environs_test
2 2
3 import ( 3 import (
4 "bytes" 4 "bytes"
5 "fmt" 5 "fmt"
6 "io"
7 "io/ioutil" 6 "io/ioutil"
8 . "launchpad.net/gocheck" 7 . "launchpad.net/gocheck"
9 "launchpad.net/juju-core/environs" 8 "launchpad.net/juju-core/environs"
10 "launchpad.net/juju-core/environs/dummy" 9 "launchpad.net/juju-core/environs/dummy"
11 "launchpad.net/juju-core/state" 10 "launchpad.net/juju-core/state"
12 "launchpad.net/juju-core/testing" 11 "launchpad.net/juju-core/testing"
13 "launchpad.net/juju-core/version" 12 "launchpad.net/juju-core/version"
14 "net/http" 13 "net/http"
15 "os" 14 "os"
16 "os/exec" 15 "os/exec"
(...skipping 23 matching lines...) Expand all
40 } 39 }
41 40
42 func (t *ToolsSuite) TearDownTest(c *C) { 41 func (t *ToolsSuite) TearDownTest(c *C) {
43 environs.VarDir = t.oldVarDir 42 environs.VarDir = t.oldVarDir
44 dummy.Reset() 43 dummy.Reset()
45 t.LoggingSuite.TearDownTest(c) 44 t.LoggingSuite.TearDownTest(c)
46 } 45 }
47 46
48 var envs *environs.Environs 47 var envs *environs.Environs
49 48
50 func mkVersion(vers string) version.Number { 49 func toolsStoragePath(vers string) string {
51 » v, err := version.Parse(vers)
52 » if err != nil {
53 » » panic(err)
54 » }
55 » return v
56 }
57
58 func mkToolsStoragePath(vers string) string {
59 return environs.ToolsStoragePath(version.Binary{ 50 return environs.ToolsStoragePath(version.Binary{
60 » » Number: mkVersion(vers), 51 » » Number: version.MustParse(vers),
61 Series: version.Current.Series, 52 Series: version.Current.Series,
62 Arch: version.Current.Arch, 53 Arch: version.Current.Arch,
63 }) 54 })
64 } 55 }
65 56
66 var _ = Suite(&ToolsSuite{}) 57 var _ = Suite(&ToolsSuite{})
67 58
68 const urlFile = "downloaded-url.txt" 59 const urlFile = "downloaded-url.txt"
69 60
70 var commandTests = []struct { 61 var commandTests = []struct {
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 222
232 err = ioutil.WriteFile(filepath.Join(dir, urlFile), []byte(" \t\n"), 064 4) 223 err = ioutil.WriteFile(filepath.Join(dir, urlFile), []byte(" \t\n"), 064 4)
233 c.Assert(err, IsNil) 224 c.Assert(err, IsNil)
234 225
235 tools, err = environs.ReadTools(vers) 226 tools, err = environs.ReadTools(vers)
236 c.Assert(tools, IsNil) 227 c.Assert(tools, IsNil)
237 c.Assert(err, ErrorMatches, "empty URL in tools directory.*") 228 c.Assert(err, ErrorMatches, "empty URL in tools directory.*")
238 } 229 }
239 230
240 func (t *ToolsSuite) TestToolsStoragePath(c *C) { 231 func (t *ToolsSuite) TestToolsStoragePath(c *C) {
241 » c.Assert(environs.ToolsStoragePath(binaryVersion(1, 2, 3, "precise", "am d64")), 232 » c.Assert(environs.ToolsStoragePath(binaryVersion("1.2.3-precise-amd64")) ,
242 Equals, "tools/juju-1.2.3-precise-amd64.tgz") 233 Equals, "tools/juju-1.2.3-precise-amd64.tgz")
243 } 234 }
244 235
245 func (t *ToolsSuite) TestToolsDir(c *C) { 236 func (t *ToolsSuite) TestToolsDir(c *C) {
246 environs.VarDir = "/var/lib/juju" 237 environs.VarDir = "/var/lib/juju"
247 » c.Assert(environs.ToolsDir(binaryVersion(1, 2, 3, "precise", "amd64")), 238 » c.Assert(environs.ToolsDir(binaryVersion("1.2.3-precise-amd64")),
248 Equals, 239 Equals,
249 "/var/lib/juju/tools/1.2.3-precise-amd64") 240 "/var/lib/juju/tools/1.2.3-precise-amd64")
250 } 241 }
251 242
252 // getTools downloads and unpacks the given tools. 243 // getTools downloads and unpacks the given tools.
253 func getTools(tools *state.Tools) error { 244 func getTools(tools *state.Tools) error {
254 resp, err := http.Get(tools.URL) 245 resp, err := http.Get(tools.URL)
255 if err != nil { 246 if err != nil {
256 return err 247 return err
257 } 248 }
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 publicContents []string // names in public storage. 388 publicContents []string // names in public storage.
398 expect string // the name we expect to find (if no error ). 389 expect string // the name we expect to find (if no error ).
399 err string // the error we expect to find (if not bla nk). 390 err string // the error we expect to find (if not bla nk).
400 }{{ 391 }{{
401 // current version should be satisfied by current tools path. 392 // current version should be satisfied by current tools path.
402 version: version.Current.Number, 393 version: version.Current.Number,
403 contents: []string{environs.ToolsStoragePath(version.Current)}, 394 contents: []string{environs.ToolsStoragePath(version.Current)},
404 expect: environs.ToolsStoragePath(version.Current), 395 expect: environs.ToolsStoragePath(version.Current),
405 }, { 396 }, {
406 // major versions don't match. 397 // major versions don't match.
407 » version: mkVersion("1.0.0"), 398 » version: version.MustParse("1.0.0"),
408 contents: []string{ 399 contents: []string{
409 » » mkToolsStoragePath("0.0.9"), 400 » » toolsStoragePath("0.0.9"),
410 }, 401 },
411 err: "no compatible tools found", 402 err: "no compatible tools found",
412 }, { 403 }, {
413 // major versions don't match. 404 // major versions don't match.
414 » version: mkVersion("1.0.0"), 405 » version: version.MustParse("1.0.0"),
415 contents: []string{ 406 contents: []string{
416 » » mkToolsStoragePath("2.0.9"), 407 » » toolsStoragePath("2.0.9"),
417 }, 408 },
418 err: "no compatible tools found", 409 err: "no compatible tools found",
419 }, { 410 }, {
420 // fall back to public storage when nothing found in private. 411 // fall back to public storage when nothing found in private.
421 » version: mkVersion("1.0.0"), 412 » version: version.MustParse("1.0.0"),
422 contents: []string{ 413 contents: []string{
423 » » mkToolsStoragePath("0.0.9"), 414 » » toolsStoragePath("0.0.9"),
424 }, 415 },
425 publicContents: []string{ 416 publicContents: []string{
426 » » mkToolsStoragePath("1.0.0"), 417 » » toolsStoragePath("1.0.0"),
427 }, 418 },
428 » expect: "public-" + mkToolsStoragePath("1.0.0"), 419 » expect: "public-" + toolsStoragePath("1.0.0"),
429 }, { 420 }, {
430 // always use private storage in preference to public storage. 421 // always use private storage in preference to public storage.
431 » version: mkVersion("1.0.0"), 422 » version: version.MustParse("1.0.0"),
432 contents: []string{ 423 contents: []string{
433 » » mkToolsStoragePath("1.0.2"), 424 » » toolsStoragePath("1.0.2"),
434 }, 425 },
435 publicContents: []string{ 426 publicContents: []string{
436 » » mkToolsStoragePath("1.0.9"), 427 » » toolsStoragePath("1.0.9"),
437 }, 428 },
438 » expect: mkToolsStoragePath("1.0.2"), 429 » expect: toolsStoragePath("1.0.2"),
439 }, { 430 }, {
440 // we'll use an earlier version if the major version number matches. 431 // we'll use an earlier version if the major version number matches.
441 » version: mkVersion("1.99.99"), 432 » version: version.MustParse("1.99.99"),
442 contents: []string{ 433 contents: []string{
443 » » mkToolsStoragePath("1.0.0"), 434 » » toolsStoragePath("1.0.0"),
444 }, 435 },
445 » expect: mkToolsStoragePath("1.0.0"), 436 » expect: toolsStoragePath("1.0.0"),
446 }, { 437 }, {
447 // check that version comparing is numeric, not alphabetical. 438 // check that version comparing is numeric, not alphabetical.
448 » version: mkVersion("1.0.0"), 439 » version: version.MustParse("1.0.0"),
449 contents: []string{ 440 contents: []string{
450 » » mkToolsStoragePath("1.0.9"), 441 » » toolsStoragePath("1.0.9"),
451 » » mkToolsStoragePath("1.0.10"), 442 » » toolsStoragePath("1.0.10"),
452 » » mkToolsStoragePath("1.0.11"), 443 » » toolsStoragePath("1.0.11"),
453 }, 444 },
454 » expect: mkToolsStoragePath("1.0.11"), 445 » expect: toolsStoragePath("1.0.11"),
455 }, { 446 }, {
456 // minor version wins over patch version. 447 // minor version wins over patch version.
457 » version: mkVersion("1.0.0"), 448 » version: version.MustParse("1.0.0"),
458 contents: []string{ 449 contents: []string{
459 » » mkToolsStoragePath("1.9.11"), 450 » » toolsStoragePath("1.9.11"),
460 » » mkToolsStoragePath("1.10.10"), 451 » » toolsStoragePath("1.10.10"),
461 » » mkToolsStoragePath("1.11.9"), 452 » » toolsStoragePath("1.11.9"),
462 }, 453 },
463 » expect: mkToolsStoragePath("1.11.9"), 454 » expect: toolsStoragePath("1.11.9"),
464 }, { 455 }, {
465 // mismatching series or architecture is ignored. 456 // mismatching series or architecture is ignored.
466 » version: mkVersion("1.0.0"), 457 » version: version.MustParse("1.0.0"),
467 contents: []string{ 458 contents: []string{
468 environs.ToolsStoragePath(version.Binary{ 459 environs.ToolsStoragePath(version.Binary{
469 » » » Number: mkVersion("1.9.9"), 460 » » » Number: version.MustParse("1.9.9"),
470 Series: "foo", 461 Series: "foo",
471 Arch: version.Current.Arch, 462 Arch: version.Current.Arch,
472 }), 463 }),
473 environs.ToolsStoragePath(version.Binary{ 464 environs.ToolsStoragePath(version.Binary{
474 » » » Number: mkVersion("1.9.9"), 465 » » » Number: version.MustParse("1.9.9"),
475 Series: version.Current.Series, 466 Series: version.Current.Series,
476 Arch: "foo", 467 Arch: "foo",
477 }), 468 }),
478 » » mkToolsStoragePath("1.0.0"), 469 » » toolsStoragePath("1.0.0"),
479 }, 470 },
480 » expect: mkToolsStoragePath("1.0.0"), 471 » expect: toolsStoragePath("1.0.0"),
481 }, 472 },
482 } 473 }
483 474
475 // putNames puts a set of names into the environ's private
476 // and public storage. The data in the private storage is
477 // the name itself; in the public storage the name is preceded with "public-".
478 func putNames(c *C, env environs.Environ, private, public []string) {
479 for _, name := range private {
480 err := env.Storage().Put(name, strings.NewReader(name), int64(le n(name)))
481 c.Assert(err, IsNil)
482 }
483 // The contents of all files in the public storage is prefixed with "pub lic-" so
484 // that we can easily tell if we've got the right thing.
485 for _, name := range public {
486 data := "public-" + name
487 err := env.PublicStorage().(environs.Storage).Put(name, strings. NewReader(data), int64(len(data)))
488 c.Assert(err, IsNil)
489 }
490 }
491
484 func (t *ToolsSuite) TestFindTools(c *C) { 492 func (t *ToolsSuite) TestFindTools(c *C) {
485 for i, tt := range findToolsTests { 493 for i, tt := range findToolsTests {
486 c.Logf("test %d", i) 494 c.Logf("test %d", i)
487 » » for _, name := range tt.contents { 495 » » putNames(c, t.env, tt.contents, tt.publicContents)
488 » » » err := t.env.Storage().Put(name, strings.NewReader(name) , int64(len(name)))
489 » » » c.Assert(err, IsNil)
490 » » }
491 » » // The contents of all files in the public storage is prefixed w ith "public-" so
492 » » // that we can easily tell if we've got the right thing.
493 » » for _, name := range tt.publicContents {
494 » » » data := "public-" + name
495 » » » err := t.env.PublicStorage().(environs.Storage).Put(name , strings.NewReader(data), int64(len(data)))
496 » » » c.Assert(err, IsNil)
497 » » }
498 vers := version.Binary{ 496 vers := version.Binary{
499 Number: tt.version, 497 Number: tt.version,
500 Series: version.Current.Series, 498 Series: version.Current.Series,
501 Arch: version.Current.Arch, 499 Arch: version.Current.Arch,
502 } 500 }
503 tools, err := environs.FindTools(t.env, vers) 501 tools, err := environs.FindTools(t.env, vers)
504 if tt.err != "" { 502 if tt.err != "" {
505 c.Assert(err, ErrorMatches, tt.err) 503 c.Assert(err, ErrorMatches, tt.err)
506 } else { 504 } else {
507 » » » c.Assert(err, IsNil) 505 » » » assertURLContents(c, tools.URL, tt.expect)
508 » » » resp, err := http.Get(tools.URL)
509 » » » c.Assert(err, IsNil)
510 » » » data, err := ioutil.ReadAll(resp.Body)
511 » » » c.Assert(err, IsNil)
512 » » » c.Assert(string(data), Equals, tt.expect, Commentf("url %s", tools.URL))
513 } 506 }
514 t.env.Destroy(nil) 507 t.env.Destroy(nil)
515 } 508 }
516 } 509 }
517 510
518 var setenvTests = []struct { 511 var setenvTests = []struct {
519 set string 512 set string
520 expect []string 513 expect []string
521 }{ 514 }{
522 {"foo=1", []string{"foo=1", "arble="}}, 515 {"foo=1", []string{"foo=1", "arble="}},
523 {"foo=", []string{"foo=", "arble="}}, 516 {"foo=", []string{"foo=", "arble="}},
524 {"arble=23", []string{"foo=bar", "arble=23"}}, 517 {"arble=23", []string{"foo=bar", "arble=23"}},
525 {"zaphod=42", []string{"foo=bar", "arble=", "zaphod=42"}}, 518 {"zaphod=42", []string{"foo=bar", "arble=", "zaphod=42"}},
526 } 519 }
527 520
528 func (*ToolsSuite) TestSetenv(c *C) { 521 func (*ToolsSuite) TestSetenv(c *C) {
529 env0 := []string{"foo=bar", "arble="} 522 env0 := []string{"foo=bar", "arble="}
530 for i, t := range setenvTests { 523 for i, t := range setenvTests {
531 c.Logf("test %d", i) 524 c.Logf("test %d", i)
532 env := make([]string, len(env0)) 525 env := make([]string, len(env0))
533 copy(env, env0) 526 copy(env, env0)
534 env = environs.Setenv(env, t.set) 527 env = environs.Setenv(env, t.set)
535 c.Check(env, DeepEquals, t.expect) 528 c.Check(env, DeepEquals, t.expect)
536 } 529 }
537 } 530 }
538 531
539 func binaryVersion(major, minor, patch int, series, arch string) version.Binary { 532 func binaryVersion(vers string) version.Binary {
540 » return version.Binary{ 533 » return version.MustParseBinary(vers)
541 » » Number: version.Number{
542 » » » Major: major,
543 » » » Minor: minor,
544 » » » Patch: patch,
545 » » },
546 » » Series: series,
547 » » Arch: arch,
548 » }
549 } 534 }
550 535
551 func newTools(major, minor, patch int, series, arch, url string) *state.Tools { 536 func newTools(vers, url string) *state.Tools {
552 return &state.Tools{ 537 return &state.Tools{
553 » » Binary: binaryVersion(major, minor, patch, series, arch), 538 » » Binary: binaryVersion(vers),
554 URL: url, 539 URL: url,
555 } 540 }
556 } 541 }
557 542
543 func assertURLContents(c *C, url string, expect string) {
544 resp, err := http.Get(url)
545 c.Assert(err, IsNil)
546 defer resp.Body.Close()
547 data, err := ioutil.ReadAll(resp.Body)
548 c.Assert(err, IsNil)
549 c.Assert(string(data), Equals, expect)
550 }
551
552 var listToolsTests = []struct {
553 major int
554 expect []string
555 }{{
556 1,
557 []string{"1.2.3-precise-i386"},
558 }, {
559 2,
560 []string{"2.2.3-precise-amd64", "2.2.3-precise-i386", "2.2.4-precise-i38 6"},
561 }, {
562 3,
563 []string{"3.2.1-quantal-amd64"},
564 }, {
565 4,
566 nil,
567 }}
568
558 func (t *ToolsSuite) TestListTools(c *C) { 569 func (t *ToolsSuite) TestListTools(c *C) {
559 » r := storageReader{ 570 » testList := []string{
560 "foo", 571 "foo",
561 "tools/.tgz", 572 "tools/.tgz",
562 "tools/juju-1.2.3-precise-i386.tgz", 573 "tools/juju-1.2.3-precise-i386.tgz",
563 "tools/juju-2.2.3-precise-amd64.tgz", 574 "tools/juju-2.2.3-precise-amd64.tgz",
564 "tools/juju-2.2.3-precise-i386.tgz", 575 "tools/juju-2.2.3-precise-i386.tgz",
565 "tools/juju-2.2.4-precise-i386.tgz", 576 "tools/juju-2.2.4-precise-i386.tgz",
566 "tools/juju-2.2-precise-amd64.tgz", 577 "tools/juju-2.2-precise-amd64.tgz",
567 » » "tools/juju-3.2.1-precise-amd64.tgz", 578 » » "tools/juju-3.2.1-quantal-amd64.tgz",
568 "xtools/juju-2.2.3-precise-amd64.tgz", 579 "xtools/juju-2.2.3-precise-amd64.tgz",
569 } 580 }
570 toolsList, err := environs.ListTools(r, 2)
571 c.Assert(err, IsNil)
572 c.Check(toolsList, DeepEquals, []*state.Tools{
573 newTools(2, 2, 3, "precise", "amd64", "<base>tools/juju-2.2.3-pr ecise-amd64.tgz"),
574 newTools(2, 2, 3, "precise", "i386", "<base>tools/juju-2.2.3-pre cise-i386.tgz"),
575 newTools(2, 2, 4, "precise", "i386", "<base>tools/juju-2.2.4-pre cise-i386.tgz"),
576 })
577 581
578 » toolsList, err = environs.ListTools(r, 3) 582 » putNames(c, t.env, testList, testList)
579 » c.Assert(err, IsNil)
580 » c.Check(toolsList, DeepEquals, []*state.Tools{
581 » » newTools(3, 2, 1, "precise", "amd64", "<base>tools/juju-3.2.1-pr ecise-amd64.tgz"),
582 » })
583 583
584 » toolsList, err = environs.ListTools(r, 4) 584 » for i, test := range listToolsTests {
585 » c.Assert(err, IsNil) 585 » » c.Logf("test %d", i)
586 » c.Check(toolsList, HasLen, 0) 586 » » toolsList, err := environs.ListTools(t.env, test.major)
587 » » c.Assert(err, IsNil)
588 » » c.Assert(toolsList.Private, HasLen, len(test.expect))
589 » » c.Assert(toolsList.Public, HasLen, len(test.expect))
590 » » for i, t := range toolsList.Private {
591 » » » vers := binaryVersion(test.expect[i])
592 » » » c.Assert(t.Binary, Equals, vers)
593 » » » assertURLContents(c, t.URL, environs.ToolsStoragePath(ve rs))
594 » » }
595 » » for i, t := range toolsList.Public {
596 » » » vers := binaryVersion(test.expect[i])
597 » » » c.Assert(t.Binary, Equals, vers)
598 » » » assertURLContents(c, t.URL, "public-"+environs.ToolsStor agePath(vers))
599 » » }
600 » }
587 } 601 }
588 602
589 var bestToolsTests = []struct { 603 var bestToolsTests = []struct {
590 » list []*state.Tools 604 » list *environs.ToolsList
591 vers version.Binary 605 vers version.Binary
592 » expect int 606 » expect *state.Tools
593 }{{ 607 }{{
608 &environs.ToolsList{},
609 binaryVersion("1.2.3-precise-amd64"),
594 nil, 610 nil,
595 binaryVersion(1, 2, 3, "precise", "amd64"),
596 -1,
597 }, { 611 }, {
598 » []*state.Tools{ 612 » &environs.ToolsList{
599 » » newTools(1, 2, 3, "precise", "amd64", ""), 613 » » Private: []*state.Tools{
600 » » newTools(1, 2, 4, "precise", "amd64", ""), 614 » » » newTools("1.2.3-precise-amd64", ""),
601 » » newTools(1, 3, 4, "precise", "amd64", ""), 615 » » » newTools("1.2.4-precise-amd64", ""),
602 » » newTools(1, 4, 4, "precise", "i386", ""), 616 » » » newTools("1.3.4-precise-amd64", ""),
603 » » newTools(1, 4, 5, "quantal", "i386", ""), 617 » » » newTools("1.4.4-precise-i386", ""),
604 » » newTools(2, 2, 3, "precise", "amd64", ""), 618 » » » newTools("1.4.5-quantal-i386", ""),
619 » » » newTools("2.2.3-precise-amd64", ""),
620 » » },
605 }, 621 },
606 » binaryVersion(1, 9, 4, "precise", "amd64"), 622 » binaryVersion("1.9.4-precise-amd64"),
607 » 2, 623 » newTools("1.3.4-precise-amd64", ""),
608 }, { 624 }, {
609 » []*state.Tools{ 625 » &environs.ToolsList{
610 » » newTools(1, 2, 3, "precise", "amd64", ""), 626 » » Private: []*state.Tools{
611 » » newTools(1, 2, 4, "precise", "amd64", ""), 627 » » » newTools("1.2.3-precise-amd64", ""),
612 » » newTools(1, 3, 4, "precise", "amd64", ""), 628 » » » newTools("1.2.4-precise-amd64", ""),
613 » » newTools(1, 4, 4, "precise", "i386", ""), 629 » » » newTools("1.3.4-precise-amd64", ""),
614 » » newTools(1, 4, 5, "quantal", "i386", ""), 630 » » » newTools("1.4.4-precise-i386", ""),
615 » » newTools(2, 2, 3, "precise", "amd64", ""), 631 » » » newTools("1.4.5-quantal-i386", ""),
632 » » » newTools("2.2.3-precise-amd64", ""),
633 » » },
616 }, 634 },
617 » binaryVersion(2, 0, 0, "precise", "amd64"), 635 » binaryVersion("2.0.0-precise-amd64"),
618 » 5, 636 » newTools("2.2.3-precise-amd64", ""),
619 }, 637 },
638 {
639 &environs.ToolsList{
640 Private: []*state.Tools{
641 newTools("1.2.3-precise-amd64", ""),
642 },
643 Public: []*state.Tools{
644 newTools("1.2.4-precise-amd64", ""),
645 },
646 },
647 binaryVersion("1.0.0-precise-amd64"),
648 newTools("1.2.3-precise-amd64", ""),
649 },
650 {
651 &environs.ToolsList{
652 Public: []*state.Tools{
653 newTools("1.2.4-precise-amd64", ""),
654 },
655 },
656 binaryVersion("1.0.0-precise-amd64"),
657 newTools("1.2.4-precise-amd64", ""),
658 },
620 } 659 }
621 660
622 func (t *ToolsSuite) TestBestTools(c *C) { 661 func (t *ToolsSuite) TestBestTools(c *C) {
623 for i, t := range bestToolsTests { 662 for i, t := range bestToolsTests {
624 c.Logf("test %d", i) 663 c.Logf("test %d", i)
625 tools := environs.BestTools(t.list, t.vers) 664 tools := environs.BestTools(t.list, t.vers)
626 » » if t.expect == -1 { 665 » » c.Assert(tools, DeepEquals, t.expect)
627 » » » c.Assert(tools, IsNil)
628 » » } else {
629 » » » c.Assert(tools, Equals, t.list[t.expect])
630 » » }
631 } 666 }
632 } 667 }
633
634 type storageReader []string
635
636 func (r storageReader) Get(name string) (io.ReadCloser, error) {
637 panic("get called on fake storage reader")
638 }
639
640 func (r storageReader) List(prefix string) ([]string, error) {
641 var l []string
642 for _, f := range r {
643 if strings.HasPrefix(f, prefix) {
644 l = append(l, f)
645 }
646 }
647 return l, nil
648 }
649
650 func (r storageReader) URL(name string) (string, error) {
651 return "<base>" + name, nil
652 }
OLDNEW
« no previous file with comments | « environs/tools.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b