flannel: updated flannel test to use pkg/testutils

reworked the flannel test to use testutils CmdAddWithResult and
CmdDelWithResult
This commit is contained in:
Mark St.Godard
2016-11-13 12:16:32 -06:00
parent e6113c6517
commit 15de81eac6
2 changed files with 56 additions and 121 deletions

View File

@ -14,13 +14,8 @@
package main
import (
"encoding/json"
"fmt"
"path/filepath"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gexec"
"testing"
)
@ -29,38 +24,3 @@ func TestFlannel(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Flannel Suite")
}
const flannelPackage = "github.com/containernetworking/cni/plugins/meta/flannel"
const noopPackage = "github.com/containernetworking/cni/plugins/test/noop"
var paths testPaths
type testPaths struct {
PathToPlugin string
CNIPath string
}
var _ = SynchronizedBeforeSuite(func() []byte {
noopBin, err := gexec.Build(noopPackage)
Expect(err).NotTo(HaveOccurred())
noopDir, _ := filepath.Split(noopBin)
pathToPlugin, err := gexec.Build(flannelPackage)
Expect(err).NotTo(HaveOccurred())
flannelDir, _ := filepath.Split(pathToPlugin)
paths := testPaths{
PathToPlugin: pathToPlugin,
CNIPath: fmt.Sprintf("%s:%s", flannelDir, noopDir),
}
data, err := json.Marshal(paths)
Expect(err).NotTo(HaveOccurred())
return data
}, func(data []byte) {
Expect(json.Unmarshal(data, &paths)).To(Succeed())
})
var _ = SynchronizedAfterSuite(func() {}, func() {
gexec.CleanupBuildArtifacts()
})