-
Notifications
You must be signed in to change notification settings - Fork 4
/
bitbucketmock.go
51 lines (41 loc) · 1.16 KB
/
bitbucketmock.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
package bitbucketmock
import (
"context"
"github.com/Interhyp/metadata-service/internal/acorn/repository"
"github.com/pkg/errors"
)
const FILTER_FAILED_USERNAME = "filterfailedusername"
type BitbucketMock struct {
}
func New() repository.Bitbucket {
return &BitbucketMock{}
}
func (b *BitbucketMock) IsBitbucket() bool {
return true
}
func (b *BitbucketMock) Setup() error {
return nil
}
func (b *BitbucketMock) SetupClient(ctx context.Context) error {
return nil
}
func (b *BitbucketMock) GetBitbucketUser(ctx context.Context, username string) (repository.BitbucketUser, error) {
return repository.BitbucketUser{
Name: username,
}, nil
}
func (b *BitbucketMock) GetBitbucketUsers(ctx context.Context, usernames []string) ([]repository.BitbucketUser, error) {
result := []repository.BitbucketUser{}
for _, username := range usernames {
result = append(result, repository.BitbucketUser{
Name: username,
})
}
return result, nil
}
func (b *BitbucketMock) FilterExistingUsernames(ctx context.Context, usernames []string) ([]string, error) {
if usernames[0] == FILTER_FAILED_USERNAME {
return []string{}, errors.New("error")
}
return usernames, nil
}