Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
b43a17f9
Unverified
Commit
b43a17f9
authored
Feb 04, 2021
by
Erik Sundell
Committed by
GitHub
Feb 04, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
increase page size and make sure the cache supports query params (#30892)
parent
56ef7c4a
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
12 deletions
+18
-12
public/app/plugins/datasource/cloud-monitoring/api.test.ts
+16
-10
public/app/plugins/datasource/cloud-monitoring/api.ts
+1
-1
public/app/plugins/datasource/cloud-monitoring/datasource.ts
+1
-1
No files found.
public/app/plugins/datasource/cloud-monitoring/api.test.ts
View file @
b43a17f9
...
...
@@ -22,7 +22,7 @@ async function getTestContext({ path = 'some-resource', options = {}, response =
const
fetchMock
=
jest
.
spyOn
(
backendSrv
,
'fetch'
);
fetchMock
.
mockImplementation
((
options
:
any
)
=>
{
const
data
=
{
[
options
.
url
.
match
(
/
([^\/]
*
)\/
*$/
)
[
1
]]:
response
};
const
data
=
{
[
options
.
url
.
match
(
/
([^\/]
*
)\/
*$/
)
!
[
1
].
split
(
'?'
)[
0
]]:
response
};
return
of
(
createFetchResponse
(
data
));
});
...
...
@@ -39,35 +39,41 @@ async function getTestContext({ path = 'some-resource', options = {}, response =
describe
(
'api'
,
()
=>
{
describe
(
'when resource was cached'
,
()
=>
{
it
(
'should return cached value and not load from source'
,
async
()
=>
{
const
path
=
'some-resource'
;
test
.
each
([
'some-resource'
,
'some-resource?some=param'
,
'test/some-resource?param'
])(
'should return cached value and not load from source'
,
async
(
path
)
=>
{
const
{
res
,
api
,
fetchMock
}
=
await
getTestContext
({
path
,
cache
:
response
});
expect
(
res
).
toEqual
(
response
);
expect
(
api
.
cache
[
path
]).
toEqual
(
response
);
expect
(
fetchMock
).
not
.
toHaveBeenCalled
();
});
}
);
});
describe
(
'when resource was not cached'
,
()
=>
{
it
(
'should return from source and not from cache'
,
async
()
=>
{
const
path
=
'some-resource'
;
test
.
each
([
'some-resource'
,
'some-resource?some=param'
,
'test/some-resource?param'
])(
'should return from source and not from cache'
,
async
(
path
)
=>
{
const
{
res
,
api
,
fetchMock
}
=
await
getTestContext
({
path
,
response
});
expect
(
res
).
toEqual
(
response
);
expect
(
api
.
cache
[
path
]).
toEqual
(
response
);
expect
(
fetchMock
).
toHaveBeenCalled
();
});
}
);
});
describe
(
'when cache should be bypassed'
,
()
=>
{
it
(
'should return from source and not from cache'
,
async
()
=>
{
test
.
each
([
'some-resource'
,
'some-resource?some=param'
,
'test/some-resource?param'
])(
'should return from source and not from cache'
,
async
(
path
)
=>
{
const
options
=
{
useCache
:
false
};
const
path
=
'some-resource'
;
const
{
res
,
fetchMock
}
=
await
getTestContext
({
path
,
response
,
cache
:
response
,
options
});
expect
(
res
).
toEqual
(
response
);
expect
(
fetchMock
).
toHaveBeenCalled
();
});
}
);
});
});
public/app/plugins/datasource/cloud-monitoring/api.ts
View file @
b43a17f9
...
...
@@ -45,7 +45,7 @@ export default class Api {
})
.
pipe
(
map
((
response
)
=>
{
const
responsePropName
=
path
.
match
(
/
([^\/]
*
)\/
*$/
)
!
[
1
];
const
responsePropName
=
path
.
match
(
/
([^\/]
*
)\/
*$/
)
!
[
1
]
.
split
(
'?'
)[
0
]
;
let
res
=
[];
if
(
response
&&
response
.
data
&&
response
.
data
[
responsePropName
])
{
res
=
response
.
data
[
responsePropName
].
map
(
responseMap
);
...
...
public/app/plugins/datasource/cloud-monitoring/datasource.ts
View file @
b43a17f9
...
...
@@ -256,7 +256,7 @@ export default class CloudMonitoringDatasource extends DataSourceWithBackend<
}
async
getSLOServices
(
projectName
:
string
):
Promise
<
Array
<
SelectableValue
<
string
>>>
{
return
this
.
api
.
get
(
`
${
this
.
templateSrv
.
replace
(
projectName
)}
/services`
,
{
return
this
.
api
.
get
(
`
${
this
.
templateSrv
.
replace
(
projectName
)}
/services
?pageSize=1000
`
,
{
responseMap
:
({
name
}:
{
name
:
string
})
=>
({
value
:
name
.
match
(
/
([^\/]
*
)\/
*$/
)
!
[
1
],
label
:
name
.
match
(
/
([^\/]
*
)\/
*$/
)
!
[
1
],
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment