Skip to content

Commit

Permalink
Add not-covered annotations
Browse files Browse the repository at this point in the history
These only apply to old podman versions (where we don't run coverage),
are "play it safe" fallbacks which Should Not Happen™, or are
transient "Loading..." states which cannot reliably be caught in tests.
  • Loading branch information
martinpitt committed Jul 13, 2023
1 parent 7878199 commit c21ae95
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions src/ContainerHealthLogs.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ const HealthcheckOnFailureActionText = {
};

const ContainerHealthLogs = ({ container, onAddNotification, state }) => {
const healthCheck = container.Config?.Healthcheck ?? container.Config?.Health ?? {};
const healthState = container.State?.Healthcheck ?? container.State?.Health ?? {};
const logs = [...(healthState.Log || [])].reverse();
const healthCheck = container.Config?.Healthcheck ?? container.Config?.Health ?? {}; // not-covered: only on old version
const healthState = container.State?.Healthcheck ?? container.State?.Health ?? {}; // not-covered: only on old version
const logs = [...(healthState.Log || [])].reverse(); // not-covered: Log should always exist, belt-and-suspenders

return (
<>
Expand Down
4 changes: 2 additions & 2 deletions src/ContainerIntegration.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const renderContainerPublishedPorts = ports => {

const items = [];
Object.entries(ports).forEach(([containerPort, hostBindings]) => {
(hostBindings ?? []).forEach(binding => {
(hostBindings ?? []).forEach(binding => { // not-covered: null was observed in the wild, but unknown how to reproduce
items.push(
<ListItem key={ containerPort + binding.HostIp + binding.HostPort }>
{ binding.HostIp || "0.0.0.0" }:{ binding.HostPort } &rarr; { containerPort }
Expand Down Expand Up @@ -88,7 +88,7 @@ const ContainerEnv = ({ containerEnv, imageEnv }) => {
};

const ContainerIntegration = ({ container, localImages }) => {
if (localImages === null) {
if (localImages === null) { // not-covered: not a stable UI state
return (
<EmptyStatePanel title={_("Loading details...")} loading />
);
Expand Down
10 changes: 5 additions & 5 deletions src/Containers.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -380,12 +380,12 @@ class Containers extends React.Component {
// this needs to get along with stub containers from image run dialog, where most properties don't exist yet
// HACK: Podman renamed `Healthcheck` to `Health` randomly
// https://github.com/containers/podman/commit/119973375
const healthcheck = container.State?.Health?.Status ?? container.State?.Healthcheck?.Status;
const status = container.State?.Status ?? "";
const healthcheck = container.State?.Health?.Status ?? container.State?.Healthcheck?.Status; // not-covered: only on old version
const status = container.State?.Status ?? ""; // not-covered: race condition

let proc = "";
let mem = "";
if (this.props.cgroupVersion == 'v1' && !container.isSystem && status == 'running') {
if (this.props.cgroupVersion == 'v1' && !container.isSystem && status == 'running') { // not-covered: only on old version
proc = <div><abbr title={_("not available")}>{_("n/a")}</abbr></div>;
mem = <div><abbr title={_("not available")}>{_("n/a")}</abbr></div>;
}
Expand Down Expand Up @@ -641,8 +641,8 @@ class Containers extends React.Component {
filtered.sort((a, b) => {
// Show unhealthy containers first
if (this.props.containers[a] && this.props.containers[b]) {
const a_health = this.props.containers[a].State.Health || this.props.containers[a].State.Healthcheck;
const b_health = this.props.containers[b].State.Health || this.props.containers[b].State.Healthcheck;
const a_health = this.props.containers[a].State.Health || this.props.containers[a].State.Healthcheck; // not-covered: only on old version
const b_health = this.props.containers[b].State.Health || this.props.containers[b].State.Healthcheck; // not-covered: only on old version
if (a_health.Status !== b_health.Status) {
if (a_health.Status === "unhealthy")
return -1;
Expand Down

0 comments on commit c21ae95

Please sign in to comment.