Skip to content

Commit 35145be

Browse files
committed
Fix unit tests
1 parent c4471a0 commit 35145be

2 files changed

Lines changed: 64 additions & 17 deletions

File tree

x-pack/plugins/ingest_manager/common/services/datasource_to_agent_datasource.test.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,6 @@ describe('Ingest Manager - storedDatasourceToAgentDatasource', () => {
109109
{
110110
type: 'test-logs',
111111
enabled: true,
112-
inputVar: 'input-value',
113-
inputVar3: {
114-
testField: 'test',
115-
},
116112
streams: [
117113
{
118114
id: 'test-logs-foo',
@@ -152,10 +148,6 @@ describe('Ingest Manager - storedDatasourceToAgentDatasource', () => {
152148
{
153149
type: 'test-logs',
154150
enabled: true,
155-
inputVar: 'input-value',
156-
inputVar3: {
157-
testField: 'test',
158-
},
159151
streams: [
160152
{
161153
id: 'test-logs-foo',

x-pack/plugins/ingest_manager/server/services/datasource.test.ts

Lines changed: 64 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,34 @@ jest.mock('./epm/packages/assets', () => {
3131
});
3232

3333
describe('Datasource service', () => {
34-
const pkgKey = 'package-1.0.0';
35-
3634
describe('assignPackageStream', () => {
37-
it('should work', async () => {
38-
const inputs = await datasourceService.assignPackageStream(pkgKey, [
35+
it('should work with cofig variables from the stream', async () => {
36+
const inputs = await datasourceService.assignPackageStream(
37+
{
38+
pkgName: 'package',
39+
pkgVersion: '1.0.0',
40+
},
41+
[
42+
{
43+
type: 'log',
44+
enabled: true,
45+
streams: [
46+
{
47+
id: 'dataset01',
48+
dataset: 'package.dataset1',
49+
enabled: true,
50+
config: {
51+
paths: {
52+
value: ['/var/log/set.log'],
53+
},
54+
},
55+
},
56+
],
57+
},
58+
]
59+
);
60+
61+
expect(inputs).toEqual([
3962
{
4063
type: 'log',
4164
enabled: true,
@@ -49,25 +72,57 @@ describe('Datasource service', () => {
4972
value: ['/var/log/set.log'],
5073
},
5174
},
75+
pkg_stream: {
76+
metricset: ['dataset1'],
77+
paths: ['/var/log/set.log'],
78+
type: 'log',
79+
},
5280
},
5381
],
5482
},
5583
]);
84+
});
85+
86+
it('should work with config variables at the input level', async () => {
87+
const inputs = await datasourceService.assignPackageStream(
88+
{
89+
pkgName: 'package',
90+
pkgVersion: '1.0.0',
91+
},
92+
[
93+
{
94+
type: 'log',
95+
enabled: true,
96+
config: {
97+
paths: {
98+
value: ['/var/log/set.log'],
99+
},
100+
},
101+
streams: [
102+
{
103+
id: 'dataset01',
104+
dataset: 'package.dataset1',
105+
enabled: true,
106+
},
107+
],
108+
},
109+
]
110+
);
56111

57112
expect(inputs).toEqual([
58113
{
59114
type: 'log',
60115
enabled: true,
116+
config: {
117+
paths: {
118+
value: ['/var/log/set.log'],
119+
},
120+
},
61121
streams: [
62122
{
63123
id: 'dataset01',
64124
dataset: 'package.dataset1',
65125
enabled: true,
66-
config: {
67-
paths: {
68-
value: ['/var/log/set.log'],
69-
},
70-
},
71126
pkg_stream: {
72127
metricset: ['dataset1'],
73128
paths: ['/var/log/set.log'],

0 commit comments

Comments
 (0)