gitRef = "f4364185253" var err error outputDir, err = ioutil.TempDir("", "bin") Expect(err).NotTo(HaveOccurred()) outputFilePath = filepath.Join(outputDir, "some-binary") }) AfterEach(func() { Expect(os.RemoveAll(outputDir)).To(Succeed()) }) It("builds the provided source code using the CNI library at the given git ref", func() { Expect(outputFilePath).NotTo(BeAnExistingFile()) err := testhelpers.BuildAt(programSource, gitRef, outputFilePath) Expect(err).NotTo(HaveOccurred()) Expect(outputFilePath).To(BeAnExistingFile()) cmd := exec.Command(outputFilePath) cmd.Env = []string{"CNI_COMMAND=VERSION"} output, err := cmd.CombinedOutput() Expect(err).To(BeAssignableToTypeOf(&exec.ExitError{})) Expect(output).To(ContainSubstring("unknown CNI_COMMAND: VERSION")) }) }) var _ = Describe("LocateCurrentGitRepo", func() { It("returns the path to the root of the CNI git repo", func() { path, err := testhelpers.LocateCurrentGitRepo()
pluginPath string ) BeforeEach(func() { pluginDir, err := ioutil.TempDir("", "plugins") Expect(err).NotTo(HaveOccurred()) pluginPath = filepath.Join(pluginDir, "test-plugin") }) AfterEach(func() { Expect(os.RemoveAll(pluginDir)).To(Succeed()) }) DescribeTable("correctly reporting plugin versions", func(gitRef string, pluginSource string, expectedVersions version.PluginInfo) { Expect(testhelpers.BuildAt([]byte(pluginSource), gitRef, pluginPath)).To(Succeed()) versionInfo, err := invoke.GetVersionInfo(pluginPath) Expect(err).NotTo(HaveOccurred()) Expect(versionInfo.SupportedVersions()).To(ConsistOf(expectedVersions.SupportedVersions())) }, Entry("historical: before VERSION was introduced", git_ref_v010, plugin_source_no_custom_versions, version.PluginSupports("0.1.0"), ), Entry("historical: when VERSION was introduced but plugins couldn't customize it", git_ref_v020_no_custom_versions, plugin_source_no_custom_versions, version.PluginSupports("0.1.0", "0.2.0"), ),