github.com/niedbalski/juju@v0.0.0-20190215020005-8ff100488e47/apiserver/facades/controller/caasfirewaller/mock_test.go (about)

     1  // Copyright 2017 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package caasfirewaller_test
     5  
     6  import (
     7  	"github.com/juju/testing"
     8  	"gopkg.in/juju/names.v2"
     9  
    10  	"github.com/juju/juju/apiserver/facades/controller/caasfirewaller"
    11  	"github.com/juju/juju/core/application"
    12  	"github.com/juju/juju/state"
    13  	statetesting "github.com/juju/juju/state/testing"
    14  )
    15  
    16  type mockState struct {
    17  	testing.Stub
    18  	application         mockApplication
    19  	applicationsWatcher *statetesting.MockStringsWatcher
    20  	appExposedWatcher   *statetesting.MockNotifyWatcher
    21  }
    22  
    23  func (st *mockState) WatchApplications() state.StringsWatcher {
    24  	st.MethodCall(st, "WatchApplications")
    25  	return st.applicationsWatcher
    26  }
    27  
    28  func (st *mockState) Application(name string) (caasfirewaller.Application, error) {
    29  	st.MethodCall(st, "Application", name)
    30  	if err := st.NextErr(); err != nil {
    31  		return nil, err
    32  	}
    33  	return &st.application, nil
    34  }
    35  
    36  func (st *mockState) FindEntity(tag names.Tag) (state.Entity, error) {
    37  	st.MethodCall(st, "FindEntity", tag)
    38  	if err := st.NextErr(); err != nil {
    39  		return nil, err
    40  	}
    41  	return &st.application, nil
    42  }
    43  
    44  type mockApplication struct {
    45  	testing.Stub
    46  	life    state.Life
    47  	exposed bool
    48  	watcher state.NotifyWatcher
    49  }
    50  
    51  func (*mockApplication) Tag() names.Tag {
    52  	panic("should not be called")
    53  }
    54  
    55  func (a *mockApplication) Life() state.Life {
    56  	a.MethodCall(a, "Life")
    57  	return a.life
    58  }
    59  
    60  func (a *mockApplication) IsExposed() bool {
    61  	a.MethodCall(a, "IsExposed")
    62  	return a.exposed
    63  }
    64  
    65  func (a *mockApplication) ApplicationConfig() (application.ConfigAttributes, error) {
    66  	a.MethodCall(a, "ApplicationConfig")
    67  	return application.ConfigAttributes{"foo": "bar"}, a.NextErr()
    68  }
    69  
    70  func (a *mockApplication) Watch() state.NotifyWatcher {
    71  	return a.watcher
    72  }