forked from flynn/flynn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrpc_test.go
66 lines (55 loc) · 1.7 KB
/
rpc_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
59
60
61
62
63
64
65
66
package main
import (
"time"
. "github.com/flynn/flynn/Godeps/_workspace/src/gopkg.in/check.v1"
"github.com/flynn/flynn/controller/client"
ct "github.com/flynn/flynn/controller/types"
)
func (s *S) TestFormationStreaming(c *C) {
before := time.Now()
release := s.createTestRelease(c, &ct.Release{})
app := s.createTestApp(c, &ct.App{Name: "streamtest-existing"})
s.createTestFormation(c, &ct.Formation{ReleaseID: release.ID, AppID: app.ID})
client, err := controller.NewClient(s.srv.URL, authKey)
c.Assert(err, IsNil)
updates, streamErr := client.StreamFormations(&before)
var existingFound bool
for f := range updates.Chan {
if f.App == nil {
break
}
if f.Release.ID == release.ID {
existingFound = true
}
}
c.Assert(existingFound, Equals, true)
c.Assert(*streamErr, IsNil)
release = s.createTestRelease(c, &ct.Release{})
app = s.createTestApp(c, &ct.App{Name: "streamtest"})
formation := s.createTestFormation(c, &ct.Formation{
ReleaseID: release.ID,
AppID: app.ID,
Processes: map[string]int{"foo": 1},
})
var out *ct.ExpandedFormation
select {
case out = <-updates.Chan:
case <-time.After(time.Second):
c.Fatal("timed out waiting for create")
}
c.Assert(out.Release, DeepEquals, release)
c.Assert(out.App, DeepEquals, app)
c.Assert(out.Processes, DeepEquals, formation.Processes)
c.Assert(out.Artifact.CreatedAt, Not(IsNil))
c.Assert(out.Artifact.ID, Equals, release.ArtifactID)
s.Delete(formationPath(app.ID, release.ID))
select {
case out = <-updates.Chan:
case <-time.After(time.Second):
c.Fatal("timed out waiting for delete")
}
c.Assert(out.Release, DeepEquals, release)
c.Assert(out.App, DeepEquals, app)
c.Assert(out.Processes, IsNil)
client.Close()
}