This repository has been archived by the owner on Aug 4, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathclient_mock_test.go
58 lines (47 loc) · 1.91 KB
/
client_mock_test.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
50
51
52
53
54
55
56
57
58
package servicefabric
import (
"fmt"
sf "github.com/jjcollinge/servicefabric"
)
type clientMock struct {
applications *sf.ApplicationItemsPage
services *sf.ServiceItemsPage
partitions *sf.PartitionItemsPage
replicas *sf.ReplicaItemsPage
instances *sf.InstanceItemsPage
getServicelabelsResult map[string]string
expectedPropertyName string
getServiceExtensionMapResult map[string]string
getPropertiesResult map[string]string
}
func (c *clientMock) GetApplications() (*sf.ApplicationItemsPage, error) {
return c.applications, nil
}
func (c *clientMock) GetServices(appName string) (*sf.ServiceItemsPage, error) {
return c.services, nil
}
func (c *clientMock) GetPartitions(appName, serviceName string) (*sf.PartitionItemsPage, error) {
return c.partitions, nil
}
func (c *clientMock) GetReplicas(appName, serviceName, partitionName string) (*sf.ReplicaItemsPage, error) {
return c.replicas, nil
}
func (c *clientMock) GetInstances(appName, serviceName, partitionName string) (*sf.InstanceItemsPage, error) {
return c.instances, nil
}
func (c *clientMock) GetServiceExtensionMap(service *sf.ServiceItem, app *sf.ApplicationItem, extensionKey string) (map[string]string, error) {
if extensionKey != traefikServiceFabricExtensionKey {
return nil, fmt.Errorf("extension key not expected value have: %s expect: %s", extensionKey, traefikServiceFabricExtensionKey)
}
return c.getServiceExtensionMapResult, nil
}
func (c *clientMock) GetServiceLabels(service *sf.ServiceItem, app *sf.ApplicationItem, prefix string) (map[string]string, error) {
return c.getServicelabelsResult, nil
}
// Note this is dumb mock the `exists`.
func (c *clientMock) GetProperties(name string) (bool, map[string]string, error) {
if c.expectedPropertyName == name {
return true, c.getPropertiesResult, nil
}
return false, nil, nil
}