-
Notifications
You must be signed in to change notification settings - Fork 4.9k
/
billing_integration_test.go
41 lines (31 loc) · 1.16 KB
/
billing_integration_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
// or more contributor license agreements. Licensed under the Elastic License;
// you may not use this file except in compliance with the Elastic License.
//go:build integration && gcp && billing
// +build integration,gcp,billing
package billing
import (
"testing"
"github.com/stretchr/testify/assert"
mbtest "github.com/elastic/beats/v7/metricbeat/mb/testing"
"github.com/elastic/beats/v7/x-pack/metricbeat/module/gcp/metrics"
)
func TestFetch(t *testing.T) {
config := metrics.GetConfigForTest(t, "billing")
config["period"] = "24h"
config["dataset_id"] = "master_gcp"
metricSet := mbtest.NewReportingMetricSetV2WithContext(t, config)
events, errs := mbtest.ReportingFetchV2WithContext(metricSet)
if len(errs) > 0 {
t.Fatalf("Expected 0 error, had %d. %v\n", len(errs), errs)
}
assert.NotEmpty(t, events)
mbtest.TestMetricsetFieldsDocumented(t, metricSet, events)
}
func TestData(t *testing.T) {
config := metrics.GetConfigForTest(t, "billing")
config["period"] = "24h"
config["dataset_id"] = "master_gcp"
metricSet := mbtest.NewFetcher(t, config)
metricSet.WriteEvents(t, "/")
}