Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increased versioncolumn coverage #278

Merged
merged 5 commits into from
Nov 17, 2024
Merged

Conversation

DeepData-Diver
Copy link
Contributor

Testing done

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests - that demonstrates feature works or fixes the issue

@DeepData-Diver DeepData-Diver requested a review from a team as a code owner November 17, 2024 02:08
@github-actions github-actions bot added dependencies Dependency related change documentation Improvements or additions to documentation tests Automated test addition or improvement labels Nov 17, 2024
Copy link
Contributor

@MarkEWaite MarkEWaite left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests look very good. One optional change that I'd like in this pull request so that we don't duplicate the junit test dependency

@MarkEWaite
Copy link
Contributor

Thanks. This looks great. For future pull requests, please use a branch named something other than "master" so that I can use standard "gh" and "git" commands to interact with your pull request.

@MarkEWaite MarkEWaite merged commit 19778a8 into jenkinsci:master Nov 17, 2024
18 checks passed
@MarkEWaite MarkEWaite removed dependencies Dependency related change documentation Improvements or additions to documentation labels Nov 17, 2024
Comment on lines +92 to +131
@Test
public void testMonitor_DifferentVersion_NotIgnored() throws IOException, InterruptedException {
VersionMonitor.DescriptorImpl descriptor = spy(new VersionMonitor.DescriptorImpl());
doReturn(false).when(descriptor).isIgnored(); // Ensure isIgnored returns false

Computer computer = mock(Computer.class);
VirtualChannel channel = mock(VirtualChannel.class);
String differentVersion = "different-version";

when(computer.getChannel()).thenReturn(channel);
when(channel.call(ArgumentMatchers.<MasterToSlaveCallable<String, IOException>>any()))
.thenReturn(differentVersion);
when(computer.isOffline()).thenReturn(false);
when(computer.getName()).thenReturn("TestComputer");

String result = descriptor.monitor(computer);

assertEquals(differentVersion, result);
verify(computer).setTemporarilyOffline(eq(true), any(VersionMonitor.RemotingVersionMismatchCause.class));
}

@Test
public void testMonitor_DifferentVersion_Ignored() throws IOException, InterruptedException {
VersionMonitor.DescriptorImpl descriptor = spy(new VersionMonitor.DescriptorImpl());
doReturn(true).when(descriptor).isIgnored(); // Ensure isIgnored returns true

Computer computer = mock(Computer.class);
VirtualChannel channel = mock(VirtualChannel.class);
String differentVersion = "different-version";

when(computer.getChannel()).thenReturn(channel);
when(channel.call(ArgumentMatchers.<MasterToSlaveCallable<String, IOException>>any()))
.thenReturn(differentVersion);
when(computer.isOffline()).thenReturn(false);

String result = descriptor.monitor(computer);

assertEquals(differentVersion, result);
verify(computer, never()).setTemporarilyOffline(anyBoolean(), any());
}
Copy link
Member

@basil basil Jan 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These newly-added tests are failing on recent cores as of jenkinsci/jenkins#9855. A hazard of using Mockito.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests Automated test addition or improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants