From f94474e24f461e691992377b95cf098761a58dde Mon Sep 17 00:00:00 2001 From: James Shubin Date: Mon, 22 Jul 2019 06:36:37 -0400 Subject: [PATCH] lang: Add the world implementation to our test suite This allows our tests to actual run the World API in them. --- lang/interpret_test.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/lang/interpret_test.go b/lang/interpret_test.go index 33304e4a..8419e783 100644 --- a/lang/interpret_test.go +++ b/lang/interpret_test.go @@ -30,6 +30,7 @@ import ( "github.com/purpleidea/mgmt/engine" "github.com/purpleidea/mgmt/engine/resources" + "github.com/purpleidea/mgmt/etcd" "github.com/purpleidea/mgmt/lang/funcs" "github.com/purpleidea/mgmt/lang/interfaces" "github.com/purpleidea/mgmt/lang/unification" @@ -1135,6 +1136,20 @@ func TestAstFunc2(t *testing.T) { afs := &afero.Afero{Fs: mmFs} // wrap so that we're implementing ioutil fs := &util.Fs{Afero: afs} + // implementation of the World API (alternatives can be substituted in) + world := &etcd.World{ + //Hostname: hostname, + //Client: etcdClient, + //MetadataPrefix: /fs, // MetadataPrefix + //StoragePrefix: "/storage", // StoragePrefix + // TODO: is this correct? (seems to work for testing) + StandaloneFs: fs, // used for static deploys + Debug: testing.Verbose(), // set via the -test.v flag to `go test` + Logf: func(format string, v ...interface{}) { + logf("world: etcd: "+format, v...) + }, + } + // use this variant, so that we don't copy the dir name // this is the equivalent to running `rsync -a src/ /` if err := util.CopyDiskContentsToFs(fs, src, "/", false); err != nil { @@ -1354,7 +1369,7 @@ func TestAstFunc2(t *testing.T) { funcs := &funcs.Engine{ Graph: graph, // not the same as the output graph! Hostname: "", // NOTE: empty b/c not used - World: nil, // NOTE: nil b/c not used + World: world, // used partially in some tests Debug: testing.Verbose(), // set via the -test.v flag to `go test` Logf: func(format string, v ...interface{}) { logf("funcs: "+format, v...)