github.com/wallyworld/juju@v0.0.0-20161013125918-6cf1bc9d917a/worker/leadership/util_test.go (about)

     1  // Copyright 2015 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package leadership_test
     5  
     6  import (
     7  	"time"
     8  
     9  	"github.com/juju/testing"
    10  
    11  	"github.com/juju/juju/core/leadership"
    12  )
    13  
    14  type StubClaimer struct {
    15  	leadership.Claimer
    16  	*testing.Stub
    17  	releases chan struct{}
    18  }
    19  
    20  func (stub *StubClaimer) ClaimLeadership(serviceName, unitName string, duration time.Duration) error {
    21  	stub.MethodCall(stub, "ClaimLeadership", serviceName, unitName, duration)
    22  	return stub.NextErr()
    23  }
    24  
    25  func (stub *StubClaimer) BlockUntilLeadershipReleased(serviceName string) error {
    26  	stub.MethodCall(stub, "BlockUntilLeadershipReleased", serviceName)
    27  	<-stub.releases
    28  	return stub.NextErr()
    29  }