Skip to content
This repository has been archived by the owner on Dec 29, 2020. It is now read-only.

Commit

Permalink
fix(test): round-trip a sample
Browse files Browse the repository at this point in the history
  • Loading branch information
ssube committed Dec 21, 2019
1 parent e5d6cb4 commit 487018f
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 2 deletions.
2 changes: 1 addition & 1 deletion schema/compat/pg_prometheus.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- these views are required for the prometheus-sql-adapter schema
-- to be fullly compatible with the pg_prometheus schema
-- to be fully compatible with the pg_prometheus schema

CREATE VIEW metrics_labels AS
SELECT
Expand Down
2 changes: 1 addition & 1 deletion schema/compat/prometheus-sql-adapter.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- these views are required for the pg_prometheus schema
-- to be fullly compatible with the prometheus-sql-adapter schema
-- to be fully compatible with the prometheus-sql-adapter schema

CREATE VIEW metric_labels AS
SELECT
Expand Down
37 changes: 37 additions & 0 deletions test/tables/samples.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
BEGIN;
-- describe samples experiment
SELECT plan(3);

\set test_uuid '''00000000-0000-0000-0000-000000000000'''

INSERT INTO metric_labels VALUES (:test_uuid, NOW(), '{"__name__":"foo"}');
INSERT INTO metric_samples VALUES (NOW(), 'foo', (
SELECT lid FROM metric_labels LIMIT 1
), 512.0);

SELECT results_eq(
E'SELECT lid, labels->>\'__name__\' FROM metric_labels',
$$VALUES
('00000000-0000-0000-0000-000000000000'::uuid, 'foo')
$$,
'labels should match'
);

SELECT results_eq(
'SELECT lid, name, value FROM metric_samples',
$$VALUES
('00000000-0000-0000-0000-000000000000'::uuid, 'foo', 512.0::float)
$$,
'samples should match'
);

SELECT results_eq(
'SELECT name, value FROM metrics',
$$VALUES
('foo', 512.0::float)
$$,
'metrics should match'
);

SELECT * FROM finish();
ROLLBACK;
File renamed without changes.

0 comments on commit 487018f

Please sign in to comment.