blob: 4016b706b7343374c87b32c47a79f3047d2bcb36 [file] [log] [blame]
Stephane Barbarie4a2564d2018-07-26 11:02:58 -04001package model
2
3import (
4 "crypto/md5"
5 "fmt"
6 "testing"
7)
8
9var (
10 BRANCH *Branch
11 HASH string
12)
13
14func Test_ConfigBranch_New(t *testing.T) {
15 node := &Node{}
16 hash := fmt.Sprintf("%x", md5.Sum([]byte("origin_hash")))
17 origin := &Revision{
18 Config: &DataRevision{},
19 Children: make(map[string][]*Revision),
20 Hash: hash,
21 branch: &Branch{},
22 WeakRef: "need to fix this",
23 }
24 txid := fmt.Sprintf("%x", md5.Sum([]byte("branch_transaction_id")))
25
26 BRANCH = NewBranch(node, txid, origin, true)
27
28 t.Logf("New branch created: %+v\n", BRANCH)
29}
30
31func Test_ConfigBranch_AddRevision(t *testing.T) {
32 HASH = fmt.Sprintf("%x", md5.Sum([]byte("revision_hash")))
33 rev := &Revision{
34 Config: &DataRevision{},
35 Children: make(map[string][]*Revision),
36 Hash: HASH,
37 branch: &Branch{},
38 WeakRef: "need to fix this",
39 }
40
41 BRANCH.revisions[HASH] = rev
42 t.Logf("Added revision: %+v\n", rev)
43}
44
45func Test_ConfigBranch_GetRevision(t *testing.T) {
46 rev := BRANCH.get(HASH)
47 t.Logf("Got revision for hash:%s rev:%+v\n", HASH, rev)
48}
49func Test_ConfigBranch_LatestRevision(t *testing.T) {
50 rev := BRANCH.GetLatest()
51 t.Logf("Got GetLatest revision:%+v\n", rev)
52}
53func Test_ConfigBranch_OriginRevision(t *testing.T) {
54 rev := BRANCH.origin
55 t.Logf("Got origin revision:%+v\n", rev)
56}