-
Notifications
You must be signed in to change notification settings - Fork 24
/
providers.go
49 lines (38 loc) · 1.05 KB
/
providers.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package mocks
import (
"sync"
types "github.com/jumppad-labs/hclconfig/types"
"github.com/jumppad-labs/jumppad/pkg/config"
mock "github.com/stretchr/testify/mock"
)
// Providers is an autogenerated mock type for the Providers type
type Providers struct {
lock sync.Mutex
mock.Mock
Providers []*Provider
returnVals map[string]error
}
func NewProviders(returnVals map[string]error) *Providers {
_m := &Providers{}
_m.Providers = []*Provider{}
_m.returnVals = returnVals
_m.lock = sync.Mutex{}
return _m
}
// GetProvider provides a mock function with given fields: c
func (_m *Providers) GetProvider(c types.Resource) config.Provider {
_m.lock.Lock()
defer _m.lock.Unlock()
// create a mock provider
m := &Provider{}
val := _m.returnVals[c.Metadata().Name]
m.On("Create").Return(val)
m.On("Destroy").Return(val)
m.On("Refresh").Return(val)
m.On("Changed").Return(false, val)
m.On("Init", mock.Anything, mock.Anything).Return(nil)
m.Init(c, nil)
// add it to the collection for easy access
_m.Providers = append(_m.Providers, m)
return m
}