// Code generated by mdatagen. DO NOT EDIT.

package metadata

import (
	"path/filepath"
	"testing"

	"github.com/google/go-cmp/cmp"
	"github.com/google/go-cmp/cmp/cmpopts"
	"github.com/stretchr/testify/require"
	"go.opentelemetry.io/collector/confmap"
	"go.opentelemetry.io/collector/confmap/confmaptest"
)

func TestMetricsBuilderConfig(t *testing.T) {
	tests := []struct {
		name string
		want MetricsBuilderConfig
	}{
		{
			name: "default",
			want: DefaultMetricsBuilderConfig(),
		},
		{
			name: "all_set",
			want: MetricsBuilderConfig{
				Metrics: MetricsConfig{
					DiskioEbsEc2InstancePerformanceExceededIops: MetricConfig{Enabled: true},
					DiskioEbsEc2InstancePerformanceExceededTp:   MetricConfig{Enabled: true},
					DiskioEbsTotalReadBytes:                     MetricConfig{Enabled: true},
					DiskioEbsTotalReadOps:                       MetricConfig{Enabled: true},
					DiskioEbsTotalReadTime:                      MetricConfig{Enabled: true},
					DiskioEbsTotalWriteBytes:                    MetricConfig{Enabled: true},
					DiskioEbsTotalWriteOps:                      MetricConfig{Enabled: true},
					DiskioEbsTotalWriteTime:                     MetricConfig{Enabled: true},
					DiskioEbsVolumePerformanceExceededIops:      MetricConfig{Enabled: true},
					DiskioEbsVolumePerformanceExceededTp:        MetricConfig{Enabled: true},
					DiskioEbsVolumeQueueLength:                  MetricConfig{Enabled: true},
					DiskioInstanceStorePerformanceExceededIops:  MetricConfig{Enabled: true},
					DiskioInstanceStorePerformanceExceededTp:    MetricConfig{Enabled: true},
					DiskioInstanceStoreTotalReadBytes:           MetricConfig{Enabled: true},
					DiskioInstanceStoreTotalReadOps:             MetricConfig{Enabled: true},
					DiskioInstanceStoreTotalReadTime:            MetricConfig{Enabled: true},
					DiskioInstanceStoreTotalWriteBytes:          MetricConfig{Enabled: true},
					DiskioInstanceStoreTotalWriteOps:            MetricConfig{Enabled: true},
					DiskioInstanceStoreTotalWriteTime:           MetricConfig{Enabled: true},
					DiskioInstanceStoreVolumeQueueLength:        MetricConfig{Enabled: true},
				},
				ResourceAttributes: ResourceAttributesConfig{
					SerialID: ResourceAttributeConfig{Enabled: true},
					VolumeID: ResourceAttributeConfig{Enabled: true},
				},
			},
		},
		{
			name: "none_set",
			want: MetricsBuilderConfig{
				Metrics: MetricsConfig{
					DiskioEbsEc2InstancePerformanceExceededIops: MetricConfig{Enabled: false},
					DiskioEbsEc2InstancePerformanceExceededTp:   MetricConfig{Enabled: false},
					DiskioEbsTotalReadBytes:                     MetricConfig{Enabled: false},
					DiskioEbsTotalReadOps:                       MetricConfig{Enabled: false},
					DiskioEbsTotalReadTime:                      MetricConfig{Enabled: false},
					DiskioEbsTotalWriteBytes:                    MetricConfig{Enabled: false},
					DiskioEbsTotalWriteOps:                      MetricConfig{Enabled: false},
					DiskioEbsTotalWriteTime:                     MetricConfig{Enabled: false},
					DiskioEbsVolumePerformanceExceededIops:      MetricConfig{Enabled: false},
					DiskioEbsVolumePerformanceExceededTp:        MetricConfig{Enabled: false},
					DiskioEbsVolumeQueueLength:                  MetricConfig{Enabled: false},
					DiskioInstanceStorePerformanceExceededIops:  MetricConfig{Enabled: false},
					DiskioInstanceStorePerformanceExceededTp:    MetricConfig{Enabled: false},
					DiskioInstanceStoreTotalReadBytes:           MetricConfig{Enabled: false},
					DiskioInstanceStoreTotalReadOps:             MetricConfig{Enabled: false},
					DiskioInstanceStoreTotalReadTime:            MetricConfig{Enabled: false},
					DiskioInstanceStoreTotalWriteBytes:          MetricConfig{Enabled: false},
					DiskioInstanceStoreTotalWriteOps:            MetricConfig{Enabled: false},
					DiskioInstanceStoreTotalWriteTime:           MetricConfig{Enabled: false},
					DiskioInstanceStoreVolumeQueueLength:        MetricConfig{Enabled: false},
				},
				ResourceAttributes: ResourceAttributesConfig{
					SerialID: ResourceAttributeConfig{Enabled: false},
					VolumeID: ResourceAttributeConfig{Enabled: false},
				},
			},
		},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			cfg := loadMetricsBuilderConfig(t, tt.name)
			diff := cmp.Diff(tt.want, cfg, cmpopts.IgnoreUnexported(MetricConfig{}, ResourceAttributeConfig{}))
			require.Emptyf(t, diff, "Config mismatch (-expected +actual):\n%s", diff)
		})
	}
}

func loadMetricsBuilderConfig(t *testing.T, name string) MetricsBuilderConfig {
	cm, err := confmaptest.LoadConf(filepath.Join("testdata", "config.yaml"))
	require.NoError(t, err)
	sub, err := cm.Sub(name)
	require.NoError(t, err)
	cfg := DefaultMetricsBuilderConfig()
	require.NoError(t, sub.Unmarshal(&cfg, confmap.WithIgnoreUnused()))
	return cfg
}

func TestResourceAttributesConfig(t *testing.T) {
	tests := []struct {
		name string
		want ResourceAttributesConfig
	}{
		{
			name: "default",
			want: DefaultResourceAttributesConfig(),
		},
		{
			name: "all_set",
			want: ResourceAttributesConfig{
				SerialID: ResourceAttributeConfig{Enabled: true},
				VolumeID: ResourceAttributeConfig{Enabled: true},
			},
		},
		{
			name: "none_set",
			want: ResourceAttributesConfig{
				SerialID: ResourceAttributeConfig{Enabled: false},
				VolumeID: ResourceAttributeConfig{Enabled: false},
			},
		},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			cfg := loadResourceAttributesConfig(t, tt.name)
			diff := cmp.Diff(tt.want, cfg, cmpopts.IgnoreUnexported(ResourceAttributeConfig{}))
			require.Emptyf(t, diff, "Config mismatch (-expected +actual):\n%s", diff)
		})
	}
}

func loadResourceAttributesConfig(t *testing.T, name string) ResourceAttributesConfig {
	cm, err := confmaptest.LoadConf(filepath.Join("testdata", "config.yaml"))
	require.NoError(t, err)
	sub, err := cm.Sub(name)
	require.NoError(t, err)
	sub, err = sub.Sub("resource_attributes")
	require.NoError(t, err)
	cfg := DefaultResourceAttributesConfig()
	require.NoError(t, sub.Unmarshal(&cfg))
	return cfg
}
