@Test public void testBuild__File_File() { try { File installFolder = ForgeTests.getTestOutputFolder("apache-install-here", true); File resultFolder = ForgeTests.getTestOutputFolder("apache-build-result", true); FileUtils.cpR( Activator.getTestData("puppetlabs-apache"), installFolder, FileUtils.DEFAULT_EXCLUDES, false, true); Metadata md = fixture.build(installFolder, resultFolder); String archiveName = md.getFullName() + '-' + md.getVersion(); File builtArchive = new File(resultFolder, archiveName + ".tar.gz"); assertTrue("Build did not build any archive", builtArchive.canRead()); File unpackFolder = ForgeTests.getTestOutputFolder("apache-unpack-result", true); InputStream input = new GZIPInputStream(new FileInputStream(builtArchive)); try { TarUtils.unpack(input, unpackFolder, false); } finally { StreamUtil.close(input); } assertTrue( "Archive doesn't contain the expected top folder", new File(unpackFolder, archiveName).isDirectory()); } catch (IOException e) { fail(e.getMessage()); } catch (IncompleteException e) { fail(e.getMessage()); } }
@Test public void testSearch__String() { try { List<ModuleInfo> hits = fixture.search("rsync"); assertFalse("No modules found matching 'rsync'", hits.isEmpty()); for (ModuleInfo mi : hits) System.out.println(mi); } catch (IOException e) { fail(e.getMessage()); } }
@Test public void testChanges__File() { try { File installFolder = ForgeTests.getTestOutputFolder("test-changes", true); File resultFolder = ForgeTests.getTestOutputFolder("test-changes-result", true); FileUtils.cpR( Activator.getTestData("puppetlabs-apache"), installFolder, FileUtils.DEFAULT_EXCLUDES, false, true); fixture.build(installFolder, resultFolder); List<File> changes = fixture.changes(installFolder); assertTrue("Unexpected changes", changes.isEmpty()); } catch (IOException e) { fail(e.getMessage()); } catch (IncompleteException e) { fail(e.getMessage()); } }
@Test public void testInstall__String_File_boolean_boolean() { try { File installFolder = ForgeTests.getTestOutputFolder("stdlib-install", true); fixture.install("puppetlabs/stdlib", installFolder, false, true); File found = new File(installFolder, "stdlib"); assertTrue("Installation did not produce the expected result", found.isDirectory()); } catch (IOException e) { e.printStackTrace(); fail(e.getMessage()); } }
@Test public void testGenerate__File_Metadata() { try { ForgeService service = ForgeFactory.eINSTANCE.createForgeService(); Metadata metadata = service.createMetadata("cloudsmith/testmodule"); File installFolder = ForgeTests.getTestOutputFolder("testmodule-install", true); installFolder.delete(); fixture.generate(installFolder, metadata); } catch (IOException e) { fail(e.getMessage()); } }
@Test public void testGetRelease__String() { try { ReleaseInfo info = fixture.getRelease("puppetlabs-apache"); assertTrue( "Unexpeced file", info.getFile().startsWith("/system/releases/p/puppetlabs/puppetlabs-apache-")); assertNotNull(info.getVersion()); } catch (FileNotFoundException e) { fail("No release found matching 'puppetlabs-apache'"); } catch (IOException e) { fail(e.getMessage()); } }