فهرست منبع

Added test to for Cloudwatch EC2 tag selection

Michael Ambrose 8 سال پیش
والد
کامیت
f0169656ba
1فایلهای تغییر یافته به همراه34 افزوده شده و 0 حذف شده
  1. 34 0
      public/app/plugins/datasource/cloudwatch/specs/datasource_specs.ts

+ 34 - 0
public/app/plugins/datasource/cloudwatch/specs/datasource_specs.ts

@@ -318,4 +318,38 @@ describe('CloudWatchDatasource', function() {
       expect(scenario.request.data.action).to.be('ListMetrics');
       expect(scenario.request.data.action).to.be('ListMetrics');
     });
     });
   });
   });
+
+  describeMetricFindQuery('ec2_instance_attribute(us-east-1, Tags.Name, { "tag:team": [ "sysops" ] })', scenario => {
+    scenario.setup(() => {
+      scenario.requestResponse = {
+        Reservations: [
+          {
+            Instances: [
+              {
+                Tags: [
+                  { Key: 'InstanceId', Value: 'i-123456' },
+                  { Key: 'Name', Value: 'Sysops Dev Server' },
+                  { Key: 'env', Value: 'dev' },
+                  { Key: 'team', Value: 'sysops' }
+                ]
+              },
+              {
+                Tags: [
+                  { Key: 'InstanceId', Value: 'i-789012' },
+                  { Key: 'Name', Value: 'Sysops Staging Server' },
+                  { Key: 'env', Value: 'staging' },
+                  { Key: 'team', Value: 'sysops' }
+                ]
+              }
+            ]
+          }
+        ]
+      };
+    });
+
+    it('should return the "Name" tag for each instance', function() {
+      expect(scenario.result[0].text).to.be('Sysops Dev Server');
+      expect(scenario.result[1].text).to.be('Sysops Staging Server');
+    });
+  });
 });
 });