Skip to content

Commit

Permalink
gofmt and lint
Browse files Browse the repository at this point in the history
  • Loading branch information
shalper2 committed Feb 22, 2023
1 parent b4eb01e commit c81d067
Showing 1 changed file with 39 additions and 39 deletions.
78 changes: 39 additions & 39 deletions receiver/snowflakereceiver/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ import (
"testing"
"time"

"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/confmap/confmaptest"
"go.opentelemetry.io/collector/receiver/scraperhelper"
"go.uber.org/multierr"
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"

"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/snowflakereceiver/internal/metadata"
)
Expand Down Expand Up @@ -110,41 +110,41 @@ func TestValidateConfig(t *testing.T) {
}

func TestLoadConfig(t *testing.T) {
t.Parallel()

cm, err := confmaptest.LoadConf(filepath.Join("testdata", "config.yaml"))
require.NoError(t, err)
// LoadConf includes the TypeStr which NewFactory does not set
id := component.NewIDWithName(typeStr, "")
cmNoStr, err := cm.Sub(id.String())
require.NoError(t, err)

testMetrics := metadata.DefaultMetricsSettings()
testMetrics.SnowflakeDatabaseBytesScannedAvg.Enabled = true
testMetrics.SnowflakeQueryBytesDeletedAvg.Enabled = false

expected := &Config{
Username: "snowflakeuser",
Password: "securepassword",
Account: "bigbusinessaccount",
Warehouse: "metricWarehouse",
ScraperControllerSettings: scraperhelper.ScraperControllerSettings{
CollectionInterval: 18 * time.Minute,
},
Role: "customMonitoringRole",
Database: "SNOWFLAKE",
Schema: "ACCOUNT_USAGE",
Metrics: testMetrics,
}

factory := NewFactory()
cfg := factory.CreateDefaultConfig()

require.NoError(t, component.UnmarshalConfig(cmNoStr, cfg))
assert.NoError(t, component.ValidateConfig(cfg))
diff := cmp.Diff(expected, cfg, cmpopts.IgnoreUnexported(metadata.MetricSettings{}))
if diff != "" {
t.Errorf("config mismatch (-expected / +actual)\n%s", diff)
}
t.Parallel()

cm, err := confmaptest.LoadConf(filepath.Join("testdata", "config.yaml"))
require.NoError(t, err)
// LoadConf includes the TypeStr which NewFactory does not set
id := component.NewIDWithName(typeStr, "")
cmNoStr, err := cm.Sub(id.String())
require.NoError(t, err)

testMetrics := metadata.DefaultMetricsSettings()
testMetrics.SnowflakeDatabaseBytesScannedAvg.Enabled = true
testMetrics.SnowflakeQueryBytesDeletedAvg.Enabled = false

expected := &Config{
Username: "snowflakeuser",
Password: "securepassword",
Account: "bigbusinessaccount",
Warehouse: "metricWarehouse",
ScraperControllerSettings: scraperhelper.ScraperControllerSettings{
CollectionInterval: 18 * time.Minute,
},
Role: "customMonitoringRole",
Database: "SNOWFLAKE",
Schema: "ACCOUNT_USAGE",
Metrics: testMetrics,
}

factory := NewFactory()
cfg := factory.CreateDefaultConfig()

require.NoError(t, component.UnmarshalConfig(cmNoStr, cfg))
assert.NoError(t, component.ValidateConfig(cfg))

diff := cmp.Diff(expected, cfg, cmpopts.IgnoreUnexported(metadata.MetricSettings{}))
if diff != "" {
t.Errorf("config mismatch (-expected / +actual)\n%s", diff)
}
}

0 comments on commit c81d067

Please sign in to comment.