Browse Source

stackdriver: test get metric types

Erik Sundell 7 years ago
parent
commit
3f4942418e
1 changed files with 33 additions and 0 deletions
  1. 33 0
      public/app/plugins/datasource/stackdriver/specs/datasource.test.ts

+ 33 - 0
public/app/plugins/datasource/stackdriver/specs/datasource.test.ts

@@ -141,4 +141,37 @@ describe('StackdriverDataSource', () => {
       });
       });
     });
     });
   });
   });
+
+  describe('when performing getMetricTypes', () => {
+    describe('and call to stackdriver api succeeds', () => {});
+    let ds;
+    let result;
+    beforeEach(async () => {
+      const backendSrv = {
+        async datasourceRequest() {
+          return Promise.resolve({
+            data: {
+              metricDescriptors: [
+                {
+                  displayName: 'test metric name 1',
+                  type: 'test metric type 1',
+                },
+                {
+                  displayName: 'test metric name 2',
+                  type: 'test metric type 2',
+                },
+              ],
+            },
+          });
+        },
+      };
+      ds = new StackdriverDataSource({}, backendSrv);
+      result = await ds.getMetricTypes();
+    });
+    it('should return successfully', () => {
+      expect(result.length).toBe(2);
+      expect(result[0].id).toBe('test metric type 1');
+      expect(result[0].name).toBe('test metric name 1');
+    });
+  });
 });
 });