~juju-qa/juju-core/1.16-packaging

« back to all changes in this revision

Viewing changes to src/launchpad.net/juju-core/charm/repo_test.go

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2013-10-10 18:07:45 UTC
  • mfrom: (1.1.10)
  • Revision ID: package-import@ubuntu.com-20131010180745-wuo0vv7hq7faavdk
Tags: 1.16.0-0ubuntu1
New upstream stable release (LP: #1219879).

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
        "launchpad.net/juju-core/charm"
22
22
        "launchpad.net/juju-core/testing"
 
23
        "launchpad.net/juju-core/testing/testbase"
23
24
)
24
25
 
25
26
type MockStore struct {
151
152
}
152
153
 
153
154
type StoreSuite struct {
154
 
        testing.LoggingSuite
 
155
        testbase.LoggingSuite
155
156
        server      *MockStore
156
157
        store       *charm.CharmStore
157
158
        oldCacheDir string
172
173
        s.server.downloads = nil
173
174
}
174
175
 
175
 
// Uses the TearDownTest from testing.LoggingSuite
 
176
// Uses the TearDownTest from testbase.LoggingSuite
176
177
 
177
178
func (s *StoreSuite) TearDownSuite(c *gc.C) {
178
179
        charm.CacheDir = s.oldCacheDir
392
393
}
393
394
 
394
395
type LocalRepoSuite struct {
395
 
        testing.LoggingSuite
 
396
        testbase.LoggingSuite
396
397
        repo       *charm.LocalRepository
397
398
        seriesPath string
398
399
}
403
404
        s.LoggingSuite.SetUpTest(c)
404
405
        root := c.MkDir()
405
406
        s.repo = &charm.LocalRepository{root}
406
 
        s.seriesPath = filepath.Join(root, "series")
 
407
        s.seriesPath = filepath.Join(root, "quantal")
407
408
        c.Assert(os.Mkdir(s.seriesPath, 0777), gc.IsNil)
408
409
}
409
410
 
422
423
 
423
424
func (s *LocalRepoSuite) TestMissingCharm(c *gc.C) {
424
425
        for i, str := range []string{
425
 
                "local:series/zebra", "local:badseries/zebra",
 
426
                "local:quantal/zebra", "local:badseries/zebra",
426
427
        } {
427
428
                c.Logf("test %d: %s", i, str)
428
429
                charmURL := charm.MustParseURL(str)
435
436
 
436
437
func (s *LocalRepoSuite) TestMissingRepo(c *gc.C) {
437
438
        c.Assert(os.RemoveAll(s.repo.Path), gc.IsNil)
438
 
        _, err := s.repo.Latest(charm.MustParseURL("local:series/zebra"))
 
439
        _, err := s.repo.Latest(charm.MustParseURL("local:quantal/zebra"))
439
440
        c.Assert(err, gc.ErrorMatches, `no repository found at ".*"`)
440
 
        _, err = s.repo.Get(charm.MustParseURL("local:series/zebra"))
 
441
        _, err = s.repo.Get(charm.MustParseURL("local:quantal/zebra"))
441
442
        c.Assert(err, gc.ErrorMatches, `no repository found at ".*"`)
442
443
        c.Assert(ioutil.WriteFile(s.repo.Path, nil, 0666), gc.IsNil)
443
 
        _, err = s.repo.Latest(charm.MustParseURL("local:series/zebra"))
 
444
        _, err = s.repo.Latest(charm.MustParseURL("local:quantal/zebra"))
444
445
        c.Assert(err, gc.ErrorMatches, `no repository found at ".*"`)
445
 
        _, err = s.repo.Get(charm.MustParseURL("local:series/zebra"))
 
446
        _, err = s.repo.Get(charm.MustParseURL("local:quantal/zebra"))
446
447
        c.Assert(err, gc.ErrorMatches, `no repository found at ".*"`)
447
448
}
448
449
 
449
450
func (s *LocalRepoSuite) TestMultipleVersions(c *gc.C) {
450
 
        charmURL := charm.MustParseURL("local:series/upgrade")
 
451
        charmURL := charm.MustParseURL("local:quantal/upgrade")
451
452
        s.addDir("upgrade1")
452
453
        rev, err := s.repo.Latest(charmURL)
453
454
        c.Assert(err, gc.IsNil)
481
482
}
482
483
 
483
484
func (s *LocalRepoSuite) TestBundle(c *gc.C) {
484
 
        charmURL := charm.MustParseURL("local:series/dummy")
 
485
        charmURL := charm.MustParseURL("local:quantal/dummy")
485
486
        s.addBundle("dummy")
486
487
 
487
488
        rev, err := s.repo.Latest(charmURL)
502
503
        err = ioutil.WriteFile(filepath.Join(samplePath, "metadata.yaml"), gibberish, 0666)
503
504
        c.Assert(err, gc.IsNil)
504
505
 
505
 
        charmURL := charm.MustParseURL("local:series/dummy")
 
506
        charmURL := charm.MustParseURL("local:quantal/dummy")
506
507
        s.addDir("dummy")
507
508
        ch, err := s.repo.Get(charmURL)
508
509
        c.Assert(err, gc.IsNil)
509
510
        c.Assert(ch.Revision(), gc.Equals, 1)
510
511
        c.Assert(c.GetTestLog(), gc.Matches, `
511
 
.* WARNING juju charm: failed to load charm at ".*/series/blah": .*
512
 
.* WARNING juju charm: failed to load charm at ".*/series/blah.charm": .*
513
 
.* WARNING juju charm: failed to load charm at ".*/series/upgrade2": .*
 
512
.* WARNING juju charm: failed to load charm at ".*/quantal/blah": .*
 
513
.* WARNING juju charm: failed to load charm at ".*/quantal/blah.charm": .*
 
514
.* WARNING juju charm: failed to load charm at ".*/quantal/upgrade2": .*
514
515
`[1:])
515
516
}
516
517
 
525
526
        c.Assert(err, gc.IsNil)
526
527
        renameSibling(c, s.addDir("dummy"), ".dummy")
527
528
        renameSibling(c, s.addBundle("dummy"), "dummy.notacharm")
528
 
        charmURL := charm.MustParseURL("local:series/dummy")
 
529
        charmURL := charm.MustParseURL("local:quantal/dummy")
529
530
 
530
531
        _, err = s.repo.Get(charmURL)
531
532
        s.checkNotFoundErr(c, err, charmURL)
539
540
        linkPath := filepath.Join(s.seriesPath, "dummy")
540
541
        err := os.Symlink(realPath, linkPath)
541
542
        c.Assert(err, gc.IsNil)
542
 
        ch, err := s.repo.Get(charm.MustParseURL("local:series/dummy"))
 
543
        ch, err := s.repo.Get(charm.MustParseURL("local:quantal/dummy"))
543
544
        c.Assert(err, gc.IsNil)
544
545
        checkDummy(c, ch, linkPath)
545
546
}