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

[Uptime] Hide integration using IP when IP not present #50138

Merged
merged 4 commits into from
Nov 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,11 @@ describe('getInfraHref', () => {
expect(getInfraKubernetesHref(summary, '')).toBeUndefined();
});

it('getInfraKubernetesHref returns undefined when checks are null', () => {
summary.state.checks![0]!.kubernetes!.pod!.uid = null;
expect(getInfraKubernetesHref(summary, '')).toBeUndefined();
});

it('getInfraIpHref creates a link for valid parameters', () => {
const result = getInfraIpHref(summary, 'bar');
expect(result).toMatchSnapshot();
Expand All @@ -161,6 +166,11 @@ describe('getInfraHref', () => {
expect(getInfraIpHref(summary, 'foo')).toBeUndefined();
});

it('getInfraIpHref returns undefined when ip is null', () => {
summary.state.checks![0].monitor.ip = null;
expect(getInfraIpHref(summary, 'foo')).toBeUndefined();
});

it('getInfraIpHref returns a url for ors between multiple ips', () => {
summary.state.checks = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,28 @@ describe('getLoggingHref', () => {
expect(getLoggingContainerHref(summary, '')).toBeUndefined();
});

it('returns undefined if necessary container is null', () => {
summary.state.checks![0].container!.id = null;
expect(getLoggingContainerHref(summary, '')).toBeUndefined();
});

it('returns undefined if necessary pod is not present', () => {
delete summary.state.checks;
expect(getLoggingKubernetesHref(summary, '')).toBeUndefined();
});

it('returns undefined if necessary pod is null', () => {
summary.state.checks![0].kubernetes!.pod!.uid = null;
expect(getLoggingKubernetesHref(summary, '')).toBeUndefined();
});

it('returns undefined ip href if ip is not present', () => {
delete summary.state.checks;
expect(getLoggingIpHref(summary, '')).toBeUndefined();
});

it('returns undefined ip href if ip is null', () => {
summary.state.checks![0].monitor.ip = null;
expect(getLoggingIpHref(summary, '')).toBeUndefined();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ export const getInfraContainerHref = (
basePath: string
): string | undefined => {
const getHref = (value: string | string[] | undefined) => {
if (value === undefined) {
return value;
if (!value) {
return undefined;
}
const ret = !Array.isArray(value) ? value : value[0];
return addBasePath(basePath, `/app/infra#/link-to/container-detail/${encodeURIComponent(ret)}`);
Expand All @@ -27,8 +27,8 @@ export const getInfraKubernetesHref = (
basePath: string
): string | undefined => {
const getHref = (value: string | string[] | undefined) => {
if (value === undefined) {
return value;
if (!value) {
return undefined;
}
const ret = !Array.isArray(value) ? value : value[0];
return addBasePath(basePath, `/app/infra#/link-to/pod-detail/${encodeURIComponent(ret)}`);
Expand All @@ -39,8 +39,8 @@ export const getInfraKubernetesHref = (

export const getInfraIpHref = (summary: MonitorSummary, basePath: string) => {
const getHref = (value: string | string[] | undefined) => {
if (value === undefined) {
return value;
if (!value) {
return undefined;
}
if (!Array.isArray(value)) {
const expression = encodeURIComponent(`host.ip : ${value}`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ export const getLoggingContainerHref = (
basePath: string
): string | undefined => {
const getHref = (value: string | string[] | undefined) => {
if (value === undefined) {
return value;
if (!value) {
return undefined;
}
const ret = !Array.isArray(value) ? value : value[0];
return addBasePath(
Expand All @@ -27,8 +27,8 @@ export const getLoggingContainerHref = (

export const getLoggingKubernetesHref = (summary: MonitorSummary, basePath: string) => {
const getHref = (value: string | string[] | undefined) => {
if (value === undefined) {
return value;
if (!value) {
return undefined;
andrewvc marked this conversation as resolved.
Show resolved Hide resolved
}
const ret = !Array.isArray(value) ? value : value[0];
return addBasePath(
Expand All @@ -41,8 +41,8 @@ export const getLoggingKubernetesHref = (summary: MonitorSummary, basePath: stri

export const getLoggingIpHref = (summary: MonitorSummary, basePath: string) => {
const getHref = (value: string | string[] | undefined) => {
if (value === undefined) {
return value;
if (!value) {
return undefined;
}
const ret = !Array.isArray(value) ? value : value[0];
return addBasePath(
Expand Down