-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbranch_test.go
43 lines (35 loc) · 1.02 KB
/
branch_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
package cloudcms
import (
"fmt"
"testing"
)
func TestBranches(t *testing.T) {
session, err := ConnectDefault()
if err != nil {
t.Fatal(err)
}
repository, err := session.CreateRepository(nil)
if err != nil {
t.Fatal(err)
}
repositoryId := ExtractId(&repository)
defer session.DeleteRepository(repositoryId)
branches, err := session.ListBranches(repositoryId, nil)
if err != nil {
t.Fatal(err)
}
for _, branch := range branches.rows {
fmt.Printf("Repository: %s, Branch: %s, Title: %s\n", repositoryId, ExtractId(&branch), branch["title"])
}
master, err := session.ReadBranch(repositoryId, "master")
if err != nil {
t.Fatal(err)
}
fmt.Printf("Repository: %s, Branch: %s, Title: %s\n", repositoryId, "master", master["title"])
tip := master.GetString("tip")
newBranch, err := session.CreateBranch(repositoryId, "master", tip, JsonObject{"title": "new branch 1"})
if err != nil {
t.Fatal(err)
}
fmt.Printf("Repository: %s, Branch: %s, Title: %s\n", repositoryId, ExtractId(&newBranch), newBranch["title"])
}