Fix all UTs
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
parent
2c038f5a7a
commit
3899618605
|
@ -1,9 +1,8 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestDecomposeTree(t *testing.T) {
|
||||
|
@ -18,6 +17,11 @@ func TestDecomposeTree(t *testing.T) {
|
|||
outputParts []SubTree
|
||||
err string
|
||||
}{
|
||||
"Single node short tree with small threshold": {
|
||||
inputTree: singleNodeTree.TreeWeighted,
|
||||
inputThreshold: 10,
|
||||
err: "[GetNodePath]: threshold too small",
|
||||
},
|
||||
"Normal tree 3x3": {
|
||||
inputTree: smallTree.TreeWeighted,
|
||||
inputThreshold: smallTree.Threshold,
|
||||
|
@ -28,11 +32,6 @@ func TestDecomposeTree(t *testing.T) {
|
|||
inputThreshold: singleNodeTree.Threshold,
|
||||
outputParts: singleNodeTree.Parts,
|
||||
},
|
||||
"Single node short tree with small threshold": {
|
||||
inputTree: singleNodeTree.TreeWeighted,
|
||||
inputThreshold: 10,
|
||||
err: "[GetNodePath]: threshold too small",
|
||||
},
|
||||
"Single branch deep tree": {
|
||||
inputTree: deepTree.TreeWeighted,
|
||||
inputThreshold: deepTree.Threshold,
|
||||
|
|
|
@ -808,133 +808,136 @@ func getWideTree() testDecomposingData {
|
|||
|
||||
func getAssimmetricTree() testDecomposingData {
|
||||
newTree := &Node{
|
||||
ID: "1.0.0.0",
|
||||
ID: "0",
|
||||
Name: "/",
|
||||
Children: []*Node{
|
||||
{
|
||||
ID: "1.1.0.0",
|
||||
ID: "01",
|
||||
Name: "folder1",
|
||||
Children: []*Node{
|
||||
{
|
||||
ID: "1.1.1.0",
|
||||
Name: "folder1",
|
||||
ID: "011",
|
||||
Name: "folder11",
|
||||
Children: []*Node{
|
||||
{
|
||||
ID: "1.1.1.1",
|
||||
Name: "folder1",
|
||||
ID: "0111",
|
||||
Name: "folder111",
|
||||
Children: []*Node{},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
ID: "012",
|
||||
Name: "folder12",
|
||||
Children: []*Node{},
|
||||
},
|
||||
{
|
||||
ID: "1.1.1.2",
|
||||
ID: "013",
|
||||
Name: "folder13",
|
||||
Children: []*Node{
|
||||
{
|
||||
ID: "0131",
|
||||
Name: "folder131",
|
||||
Children: []*Node{
|
||||
{
|
||||
ID: "01311",
|
||||
Name: "folder1311",
|
||||
Children: []*Node{
|
||||
{
|
||||
ID: "013111",
|
||||
Name: "folder13111",
|
||||
Children: []*Node{
|
||||
{
|
||||
ID: "0131111",
|
||||
Name: "folder131111",
|
||||
Children: []*Node{},
|
||||
},
|
||||
{
|
||||
ID: "0131112",
|
||||
Name: "folder131112",
|
||||
Children: []*Node{},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
ID: "0132",
|
||||
Name: "folder132",
|
||||
Children: []*Node{
|
||||
{
|
||||
ID: "01321",
|
||||
Name: "folder1321",
|
||||
Children: []*Node{},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
ID: "0133",
|
||||
Name: "folder133",
|
||||
Children: []*Node{},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
ID: "02",
|
||||
Name: "folder2",
|
||||
Children: []*Node{
|
||||
{
|
||||
ID: "1.1.1.1.1",
|
||||
Name: "folder1.1.1.1.1",
|
||||
Children: []*Node{
|
||||
{
|
||||
ID: "1.1.1.1.1.1",
|
||||
Name: "folder1.1.1.1.1.1",
|
||||
Children: []*Node{},
|
||||
},
|
||||
{
|
||||
ID: "1.1.1.1.1.2",
|
||||
Name: "folder1.1.1.1.1.2",
|
||||
Children: []*Node{
|
||||
{
|
||||
ID: "1.1.1.1.1.2.1",
|
||||
Name: "folder1.1.1.1.1.2.1",
|
||||
Children: []*Node{},
|
||||
}, {
|
||||
ID: "1.1.1.1.1.2.2",
|
||||
Name: "folder1.1.1.1.1.2.2",
|
||||
Children: []*Node{},
|
||||
}, {
|
||||
ID: "1.1.1.1.1.2.3",
|
||||
Name: "folder1.1.1.1.1.2.3",
|
||||
Children: []*Node{},
|
||||
}, {
|
||||
ID: "1.1.1.1.1.2.4",
|
||||
Name: "folder1.1.1.1.1.2.4",
|
||||
Children: []*Node{{
|
||||
ID: "1.1.1.1.1.2.4.1",
|
||||
Name: "folder1.1.1.1.1.2.4.1",
|
||||
Children: []*Node{{
|
||||
ID: "1.1.1.1.1.2.4.1.1",
|
||||
Name: "folder1.1.1.1.1.2.4.1.1",
|
||||
Children: []*Node{},
|
||||
}, {
|
||||
ID: "1.1.1.1.1.2.4.1.2",
|
||||
Name: "folder1.1.1.1.1.2.4.1.2",
|
||||
Children: []*Node{},
|
||||
}},
|
||||
}},
|
||||
}, {
|
||||
ID: "1.1.1.1.1.2.5",
|
||||
Name: "folder1.1.1.1.1.2.5",
|
||||
Children: []*Node{},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
ID: "1.1.1.3",
|
||||
ID: "03",
|
||||
Name: "folder3",
|
||||
Children: []*Node{},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
ID: "1.1.2.0",
|
||||
Name: "folder2",
|
||||
Children: []*Node{
|
||||
{
|
||||
ID: "1.1.2.1",
|
||||
Name: "folder1",
|
||||
ID: "04",
|
||||
Name: "folder4",
|
||||
Children: []*Node{},
|
||||
},
|
||||
{
|
||||
ID: "1.1.2.2",
|
||||
Name: "folder2",
|
||||
Children: []*Node{},
|
||||
},
|
||||
{
|
||||
ID: "1.1.2.3",
|
||||
Name: "folder3",
|
||||
Children: []*Node{},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
return testDecomposingData{
|
||||
TreeWeighted: newTree.WeightingTreeWithStack(),
|
||||
Threshold: 200,
|
||||
Threshold: 220,
|
||||
Parts: []SubTree{
|
||||
{
|
||||
path: "/folder1",
|
||||
path: "/folder1/folder13/folder131",
|
||||
tree: &Node{
|
||||
ID: "1.1.1.0",
|
||||
Name: "folder1",
|
||||
ID: "01311",
|
||||
Name: "folder1311",
|
||||
Children: []*Node{
|
||||
{
|
||||
ID: "1.1.1.1",
|
||||
Name: "folder1",
|
||||
ID: "013111",
|
||||
Name: "folder13111",
|
||||
Children: []*Node{
|
||||
{
|
||||
ID: "0131111",
|
||||
Name: "folder131111",
|
||||
Children: []*Node{},
|
||||
},
|
||||
{
|
||||
ID: "1.1.1.2",
|
||||
Name: "folder2",
|
||||
ID: "0131112",
|
||||
Name: "folder131112",
|
||||
Children: []*Node{},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
ID: "1.1.1.3",
|
||||
Name: "folder3",
|
||||
path: "/folder1/folder13",
|
||||
tree: &Node{
|
||||
ID: "0132",
|
||||
Name: "folder132",
|
||||
Children: []*Node{
|
||||
{
|
||||
ID: "01321",
|
||||
Name: "folder1321",
|
||||
Children: []*Node{},
|
||||
},
|
||||
},
|
||||
|
@ -943,190 +946,17 @@ func getAssimmetricTree() testDecomposingData {
|
|||
{
|
||||
path: "/folder1",
|
||||
tree: &Node{
|
||||
ID: "1.1.2.0",
|
||||
Name: "folder2",
|
||||
ID: "013",
|
||||
Name: "folder13",
|
||||
Children: []*Node{
|
||||
{
|
||||
ID: "1.1.2.1",
|
||||
Name: "folder1",
|
||||
ID: "0131",
|
||||
Name: "folder131",
|
||||
Children: []*Node{},
|
||||
},
|
||||
{
|
||||
ID: "1.1.2.2",
|
||||
Name: "folder2",
|
||||
Children: []*Node{},
|
||||
},
|
||||
{
|
||||
ID: "1.1.2.3",
|
||||
Name: "folder3",
|
||||
Children: []*Node{},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "/folder1",
|
||||
tree: &Node{
|
||||
ID: "1.1.3.0",
|
||||
Name: "folder3",
|
||||
Children: []*Node{
|
||||
{
|
||||
ID: "1.1.3.1",
|
||||
Name: "folder1",
|
||||
Children: []*Node{},
|
||||
},
|
||||
{
|
||||
ID: "1.1.3.2",
|
||||
Name: "folder2",
|
||||
Children: []*Node{},
|
||||
},
|
||||
{
|
||||
ID: "1.1.3.3",
|
||||
Name: "folder3",
|
||||
Children: []*Node{},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "/folder2",
|
||||
tree: &Node{
|
||||
ID: "1.2.1.0",
|
||||
Name: "folder1",
|
||||
Children: []*Node{
|
||||
{
|
||||
ID: "1.2.1.1",
|
||||
Name: "folder1",
|
||||
Children: []*Node{},
|
||||
},
|
||||
{
|
||||
ID: "1.2.1.2",
|
||||
Name: "folder2",
|
||||
Children: []*Node{},
|
||||
},
|
||||
{
|
||||
ID: "1.2.1.3",
|
||||
Name: "folder3",
|
||||
Children: []*Node{},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "/folder2",
|
||||
tree: &Node{
|
||||
ID: "1.2.2.0",
|
||||
Name: "folder2",
|
||||
Children: []*Node{
|
||||
{
|
||||
ID: "1.2.2.1",
|
||||
Name: "folder1",
|
||||
Children: []*Node{},
|
||||
},
|
||||
{
|
||||
ID: "1.2.2.2",
|
||||
Name: "folder2",
|
||||
Children: []*Node{},
|
||||
},
|
||||
{
|
||||
ID: "1.2.2.3",
|
||||
Name: "folder3",
|
||||
Children: []*Node{},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "/folder2",
|
||||
tree: &Node{
|
||||
ID: "1.2.3.0",
|
||||
Name: "folder3",
|
||||
Children: []*Node{
|
||||
{
|
||||
ID: "1.2.3.1",
|
||||
Name: "folder1",
|
||||
Children: []*Node{},
|
||||
},
|
||||
{
|
||||
ID: "1.2.3.2",
|
||||
Name: "folder2",
|
||||
Children: []*Node{},
|
||||
},
|
||||
{
|
||||
ID: "1.2.3.3",
|
||||
Name: "folder3",
|
||||
Children: []*Node{},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "/folder3",
|
||||
tree: &Node{
|
||||
ID: "1.3.1.0",
|
||||
Name: "folder1",
|
||||
Children: []*Node{
|
||||
{
|
||||
ID: "1.3.1.1",
|
||||
Name: "folder1",
|
||||
Children: []*Node{},
|
||||
},
|
||||
{
|
||||
ID: "1.3.1.2",
|
||||
Name: "folder2",
|
||||
Children: []*Node{},
|
||||
},
|
||||
{
|
||||
ID: "1.3.1.3",
|
||||
Name: "folder3",
|
||||
Children: []*Node{},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "/folder3",
|
||||
tree: &Node{
|
||||
ID: "1.3.2.0",
|
||||
Name: "folder2",
|
||||
Children: []*Node{
|
||||
{
|
||||
ID: "1.3.2.1",
|
||||
Name: "folder1",
|
||||
Children: []*Node{},
|
||||
},
|
||||
{
|
||||
ID: "1.3.2.2",
|
||||
Name: "folder2",
|
||||
Children: []*Node{},
|
||||
},
|
||||
{
|
||||
ID: "1.3.2.3",
|
||||
Name: "folder3",
|
||||
Children: []*Node{},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "/folder3",
|
||||
tree: &Node{
|
||||
ID: "1.3.3.0",
|
||||
Name: "folder3",
|
||||
Children: []*Node{
|
||||
{
|
||||
ID: "1.3.3.1",
|
||||
Name: "folder1",
|
||||
Children: []*Node{},
|
||||
},
|
||||
{
|
||||
ID: "1.3.3.2",
|
||||
Name: "folder2",
|
||||
Children: []*Node{},
|
||||
},
|
||||
{
|
||||
ID: "1.3.3.3",
|
||||
Name: "folder3",
|
||||
ID: "0133",
|
||||
Name: "folder133",
|
||||
Children: []*Node{},
|
||||
},
|
||||
},
|
||||
|
@ -1135,21 +965,46 @@ func getAssimmetricTree() testDecomposingData {
|
|||
{
|
||||
path: "/",
|
||||
tree: &Node{
|
||||
ID: "1.0.0.0",
|
||||
ID: "01",
|
||||
Name: "folder1",
|
||||
Children: []*Node{
|
||||
{
|
||||
ID: "011",
|
||||
Name: "folder11",
|
||||
Children: []*Node{
|
||||
{
|
||||
ID: "0111",
|
||||
Name: "folder111",
|
||||
Children: []*Node{},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
ID: "012",
|
||||
Name: "folder12",
|
||||
Children: []*Node{},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "/",
|
||||
tree: &Node{
|
||||
ID: "0",
|
||||
Name: "/",
|
||||
Children: []*Node{
|
||||
{
|
||||
ID: "1.1.0.0",
|
||||
Name: "folder1",
|
||||
ID: "04",
|
||||
Name: "folder4",
|
||||
Children: []*Node{},
|
||||
},
|
||||
{
|
||||
ID: "1.2.0.0",
|
||||
ID: "02",
|
||||
Name: "folder2",
|
||||
Children: []*Node{},
|
||||
},
|
||||
{
|
||||
ID: "1.3.0.0",
|
||||
ID: "03",
|
||||
Name: "folder3",
|
||||
Children: []*Node{},
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue