Yum { public InstallFixedYumCommand installFixedVersion(YumPackageName yumPackage) { return new InstallFixedYumCommand(terminal, yumPackage); } Yum(Terminal terminal); Optional<YumPackageName> queryInstalled(TaskContext context, String packageName); InstallFixedYumCommand installFixedVersion(YumPackageName yumPackage); GenericYumCommand install(YumPackageName... packages); GenericYumCommand install(String package1, String... packages); GenericYumCommand install(List<String> packages); GenericYumCommand upgrade(YumPackageName... packages); GenericYumCommand upgrade(String package1, String... packages); GenericYumCommand upgrade(List<String> packages); GenericYumCommand remove(YumPackageName... packages); GenericYumCommand remove(String package1, String... packages); GenericYumCommand remove(List<String> packages);  }
@Test public void testWithVersionLock() { terminal.expectCommand("yum --quiet versionlock list 2>&1", 0, "Repository chef_rpms-release is listed more than once in the configuration\n" + "0:chef-12.21.1-1.el7.*\n"); terminal.expectCommand("yum versionlock add --assumeyes \"0:package-1-0.10-654.el7.*\" 2>&1"); terminal.expectCommand( "yum install --assumeyes 0:package-1-0.10-654.el7.x86_64 2>&1", 0, "installing"); assertTrue(yum.installFixedVersion(YumPackageName.fromString("0:package-1-0.10-654.el7.x86_64")).converge(taskContext)); }
@Test public void testWithDifferentVersionLock() { terminal.expectCommand("yum --quiet versionlock list 2>&1", 0, "Repository chef_rpms-release is listed more than once in the configuration\n" + "0:chef-12.21.1-1.el7.*\n" + "0:package-1-0.1-8.el7.*\n"); terminal.expectCommand("yum versionlock delete \"0:package-1-0.1-8.el7.*\" 2>&1"); terminal.expectCommand("yum versionlock add --assumeyes --enablerepo=somerepo \"0:package-1-0.10-654.el7.*\" 2>&1"); terminal.expectCommand( "yum install --assumeyes --enablerepo=somerepo 0:package-1-0.10-654.el7 2>&1", 0, "Nothing to do\n"); assertTrue(yum .installFixedVersion(YumPackageName.fromString("0:package-1-0.10-654.el7")) .enableRepo("somerepo") .converge(taskContext)); }
@Test public void testWithExistingVersionLock() { terminal.expectCommand("yum --quiet versionlock list 2>&1", 0, "Repository chef_rpms-release is listed more than once in the configuration\n" + "0:chef-12.21.1-1.el7.*\n" + "0:package-1-0.10-654.el7.*\n"); terminal.expectCommand( "yum install --assumeyes 0:package-1-0.10-654.el7 2>&1", 0, "Nothing to do\n"); assertFalse(yum.installFixedVersion(YumPackageName.fromString("0:package-1-0.10-654.el7")).converge(taskContext)); }
@Test public void testWithDowngrade() { terminal.expectCommand("yum --quiet versionlock list 2>&1", 0, "Repository chef_rpms-release is listed more than once in the configuration\n" + "0:chef-12.21.1-1.el7.*\n" + "0:package-1-0.10-654.el7.*\n"); terminal.expectCommand( "yum install --assumeyes 0:package-1-0.10-654.el7 2>&1", 0, "Package matching package-1-0.10-654.el7 already installed. Checking for update.\n" + "Nothing to do\n"); terminal.expectCommand("yum downgrade --assumeyes 0:package-1-0.10-654.el7 2>&1"); assertTrue(yum.installFixedVersion(YumPackageName.fromString("0:package-1-0.10-654.el7")).converge(taskContext)); }