Simplify paths to yaml tests
This commit is contained in:
parent
97829406fe
commit
d11af440a4
@ -17,7 +17,7 @@ func (m *mockListener) Update(tree ACLTree) {}
|
|||||||
func (m *mockListener) Rebuild(tree ACLTree) {}
|
func (m *mockListener) Rebuild(tree ACLTree) {}
|
||||||
|
|
||||||
func TestACLTree_UserJoinBuild(t *testing.T) {
|
func TestACLTree_UserJoinBuild(t *testing.T) {
|
||||||
thr, err := threadbuilder.NewThreadBuilderFromFile("threadbuilder/userjoinexample.yml")
|
thr, err := threadbuilder.NewThreadBuilderWithTestName("userjoinexample.yml")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -52,7 +52,7 @@ func TestACLTree_UserJoinBuild(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestACLTree_UserRemoveBuild(t *testing.T) {
|
func TestACLTree_UserRemoveBuild(t *testing.T) {
|
||||||
thr, err := threadbuilder.NewThreadBuilderFromFile("threadbuilder/userremoveexample.yml")
|
thr, err := threadbuilder.NewThreadBuilderWithTestName("userremoveexample.yml")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -83,7 +83,7 @@ func TestACLTree_UserRemoveBuild(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestACLTree_UserRemoveBeforeBuild(t *testing.T) {
|
func TestACLTree_UserRemoveBeforeBuild(t *testing.T) {
|
||||||
thr, err := threadbuilder.NewThreadBuilderFromFile("threadbuilder/userremovebeforeexample.yml")
|
thr, err := threadbuilder.NewThreadBuilderWithTestName("userremovebeforeexample.yml")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -115,7 +115,7 @@ func TestACLTree_UserRemoveBeforeBuild(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestACLTree_InvalidSnapshotBuild(t *testing.T) {
|
func TestACLTree_InvalidSnapshotBuild(t *testing.T) {
|
||||||
thr, err := threadbuilder.NewThreadBuilderFromFile("threadbuilder/invalidsnapshotexample.yml")
|
thr, err := threadbuilder.NewThreadBuilderWithTestName("invalidsnapshotexample.yml")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -146,7 +146,7 @@ func TestACLTree_InvalidSnapshotBuild(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestACLTree_ValidSnapshotBuild(t *testing.T) {
|
func TestACLTree_ValidSnapshotBuild(t *testing.T) {
|
||||||
thr, err := threadbuilder.NewThreadBuilderFromFile("threadbuilder/validsnapshotexample.yml")
|
thr, err := threadbuilder.NewThreadBuilderWithTestName("validsnapshotexample.yml")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,7 +7,7 @@ package acltree
|
|||||||
//}
|
//}
|
||||||
//
|
//
|
||||||
//func TestACLTreeBuilder_UserJoinCorrectHeadsAndLen(t *testing.T) {
|
//func TestACLTreeBuilder_UserJoinCorrectHeadsAndLen(t *testing.T) {
|
||||||
// thread, err := threadbuilder.NewThreadBuilderFromFile("threadbuilder/userjoinexample.yml")
|
// thread, err := threadbuilder.NewThreadBuilderWithTestName("threadbuilder/userjoinexample.yml")
|
||||||
// if err != nil {
|
// if err != nil {
|
||||||
// t.Fatal(err)
|
// t.Fatal(err)
|
||||||
// }
|
// }
|
||||||
@ -22,7 +22,7 @@ package acltree
|
|||||||
//}
|
//}
|
||||||
//
|
//
|
||||||
//func TestTreeBuilder_UserJoinTestTreeIterate(t *testing.T) {
|
//func TestTreeBuilder_UserJoinTestTreeIterate(t *testing.T) {
|
||||||
// thread, err := threadbuilder.NewThreadBuilderFromFile("threadbuilder/userjoinexample.yml")
|
// thread, err := threadbuilder.NewThreadBuilderWithTestName("threadbuilder/userjoinexample.yml")
|
||||||
// if err != nil {
|
// if err != nil {
|
||||||
// t.Fatal(err)
|
// t.Fatal(err)
|
||||||
// }
|
// }
|
||||||
@ -43,7 +43,7 @@ package acltree
|
|||||||
//}
|
//}
|
||||||
//
|
//
|
||||||
//func TestTreeBuilder_UserRemoveTestTreeIterate(t *testing.T) {
|
//func TestTreeBuilder_UserRemoveTestTreeIterate(t *testing.T) {
|
||||||
// thread, err := threadbuilder.NewThreadBuilderFromFile("threadbuilder/userremoveexample.yml")
|
// thread, err := threadbuilder.NewThreadBuilderWithTestName("threadbuilder/userremoveexample.yml")
|
||||||
// if err != nil {
|
// if err != nil {
|
||||||
// t.Fatal(err)
|
// t.Fatal(err)
|
||||||
// }
|
// }
|
||||||
|
|||||||
@ -8,7 +8,7 @@ package plaintextdocument
|
|||||||
//)
|
//)
|
||||||
//
|
//
|
||||||
//func TestDocument_Build(t *testing.T) {
|
//func TestDocument_Build(t *testing.T) {
|
||||||
// thread, err := threadbuilder.NewThreadBuilderFromFile("threadbuilder/userjoinexample.yml")
|
// thread, err := threadbuilder.NewThreadBuilderWithTestName("threadbuilder/userjoinexample.yml")
|
||||||
// if err != nil {
|
// if err != nil {
|
||||||
// t.Fatal(err)
|
// t.Fatal(err)
|
||||||
// }
|
// }
|
||||||
@ -28,7 +28,7 @@ package plaintextdocument
|
|||||||
//}
|
//}
|
||||||
//
|
//
|
||||||
//func TestDocument_Update(t *testing.T) {
|
//func TestDocument_Update(t *testing.T) {
|
||||||
// thread, err := threadbuilder.NewThreadBuilderFromFile("threadbuilder/userjoinexample.yml")
|
// thread, err := threadbuilder.NewThreadBuilderWithTestName("threadbuilder/userjoinexample.yml")
|
||||||
// if err != nil {
|
// if err != nil {
|
||||||
// t.Fatal(err)
|
// t.Fatal(err)
|
||||||
// }
|
// }
|
||||||
|
|||||||
@ -4,8 +4,10 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/aclchanges"
|
"github.com/anytypeio/go-anytype-infrastructure-experiments/aclchanges"
|
||||||
|
"github.com/anytypeio/go-anytype-infrastructure-experiments/testutils/yamltests"
|
||||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/slice"
|
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/slice"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"path"
|
||||||
|
|
||||||
"github.com/gogo/protobuf/proto"
|
"github.com/gogo/protobuf/proto"
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
@ -46,6 +48,11 @@ func NewThreadBuilder(keychain *Keychain) *ThreadBuilder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewThreadBuilderWithTestName(name string) (*ThreadBuilder, error) {
|
||||||
|
filePath := path.Join(yamltests.Path(), name)
|
||||||
|
return NewThreadBuilderFromFile(filePath)
|
||||||
|
}
|
||||||
|
|
||||||
func NewThreadBuilderFromFile(file string) (*ThreadBuilder, error) {
|
func NewThreadBuilderFromFile(file string) (*ThreadBuilder, error) {
|
||||||
content, err := ioutil.ReadFile(file)
|
content, err := ioutil.ReadFile(file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func Test_YamlParse(t *testing.T) {
|
func Test_YamlParse(t *testing.T) {
|
||||||
tb, _ := NewThreadBuilderFromFile("userjoinexample.yml")
|
tb, _ := NewThreadBuilderWithTestName("userjoinexample.yml")
|
||||||
gr, _ := tb.Graph()
|
gr, _ := tb.Graph()
|
||||||
fmt.Println(gr)
|
fmt.Println(gr)
|
||||||
}
|
}
|
||||||
|
|||||||
15
testutils/yamltests/path.go
Normal file
15
testutils/yamltests/path.go
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
package yamltests
|
||||||
|
|
||||||
|
import (
|
||||||
|
"path/filepath"
|
||||||
|
"runtime"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
_, b, _, _ = runtime.Caller(0)
|
||||||
|
basepath = filepath.Dir(b)
|
||||||
|
)
|
||||||
|
|
||||||
|
func Path() string {
|
||||||
|
return basepath
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user