-
Notifications
You must be signed in to change notification settings - Fork 3
/
deserialize_test.go
30 lines (21 loc) · 968 Bytes
/
deserialize_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
package graph
import (
"context"
"testing"
)
func TestBuildGraph(t *testing.T) {
ctxt := context.Background()
mykin := "mykin"
kinesisResource := MakeResource(mykin, nil, &kinesis{ctxt: ctxt}, func(x interface{}) (string, error) { return "", nil }, func(x interface{}) error { return nil })
dynamoResource := MakeResource("mydyn", nil, &dynamo{ctxt: ctxt}, func(x interface{}) (string, error) { return "", nil }, func(x interface{}) error { return nil })
deploymentResource := MakeResource("mydep1", []Dependency{{"mykin", "Arn", "KinesisArn"}}, &deployment{ctxt: ctxt}, func(x interface{}) (string, error) { return "", nil }, func(x interface{}) error { return nil })
resources := []Resource{kinesisResource, dynamoResource, deploymentResource}
g := buildGraph(resources)
t.Logf("graph = %v\n", g)
if g.vertices() != 3 {
t.Fatal("vertices incorrect")
}
if len(g.adjascent(0)) != 1 || g.adjascent(0)[0] != 2 {
t.Fatal("incorrect edges")
}
}