-
Notifications
You must be signed in to change notification settings - Fork 0
/
company_mock.go
59 lines (51 loc) · 2.21 KB
/
company_mock.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
59
package logic
import (
v1 "github.com/klovercloud-ci-cd/integration-manager/core/v1"
"github.com/klovercloud-ci-cd/integration-manager/core/v1/repository"
"github.com/klovercloud-ci-cd/integration-manager/core/v1/service"
)
type mockCompanyService struct {
repo repository.CompanyRepository
client service.HttpClient
}
func (m mockCompanyService) Delete(companyId string) error {
//TODO implement me
panic("implement me")
}
func (m mockCompanyService) GetByName(name string, status v1.StatusQueryOption) v1.Company {
//TODO implement me
panic("implement me")
}
func (m mockCompanyService) GetByCompanyId(id string) v1.Company {
company := v1.Company{MetaData: struct {
Labels map[string]string `bson:"labels" json:"labels" yaml:"labels"`
NumberOfConcurrentProcess int64 `bson:"number_of_concurrent_process" json:"number_of_concurrent_process" yaml:"number_of_concurrent_process"`
TotalProcessPerDay int64 `bson:"total_process_per_day" json:"total_process_per_day" yaml:"total_process_per_day"`
}{Labels: nil, NumberOfConcurrentProcess: 10, TotalProcessPerDay: 10}}
return company
}
func (m mockCompanyService) Store(company v1.Company) error {
return m.repo.Store(company)
}
func (m mockCompanyService) GetCompanies(option v1.CompanyQueryOption, status v1.StatusQueryOption) []v1.Company {
companies, _ := m.repo.GetCompanies(option, status)
return companies
}
func (m mockCompanyService) initMockCompanyData() {
company := v1.Company{
MetaData: struct {
Labels map[string]string `bson:"labels" json:"labels" yaml:"labels"`
NumberOfConcurrentProcess int64 `bson:"number_of_concurrent_process" json:"number_of_concurrent_process" yaml:"number_of_concurrent_process"`
TotalProcessPerDay int64 `bson:"total_process_per_day" json:"total_process_per_day" yaml:"total_process_per_day"`
}{Labels: nil, NumberOfConcurrentProcess: 10, TotalProcessPerDay: 10},
Id: "1",
}
m.Store(company)
}
// NewMockCompanyService returns Company type service
func NewMockCompanyService(repo repository.CompanyRepository, client service.HttpClient) service.Company {
return &mockCompanyService{
repo: repo,
client: client,
}
}