forked from refiito/pipes-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_service.go
49 lines (41 loc) · 1.02 KB
/
test_service.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 main
import (
"code.google.com/p/goauth2/oauth"
"encoding/json"
"fmt"
)
const TestServiceName = "test_service"
const p1Name = "Without surrounding spaces"
const p2Name = "Trailing space "
const p3Name = " Leading space"
const p4Name = " Leading and trailing spaces "
const p5Name = " "
type TestService struct {
emptyService
workspaceID int
token oauth.Token
}
func (s *TestService) Name() string {
return TestServiceName
}
func (s *TestService) WorkspaceID() int {
return s.workspaceID
}
func (s *TestService) keyFor(pipeID string) string {
return fmt.Sprintf("test:%s", pipeID)
}
func (s *TestService) setAuthData(b []byte) error {
if err := json.Unmarshal(b, &s.token); err != nil {
return err
}
return nil
}
func (s *TestService) Projects() ([]*Project, error) {
var ps []*Project
ps = append(ps, &Project{Name: p1Name})
ps = append(ps, &Project{Name: p2Name})
ps = append(ps, &Project{Name: p3Name})
ps = append(ps, &Project{Name: p4Name})
ps = append(ps, &Project{Name: p5Name})
return ps, nil
}