// Code generated by mdatagen. DO NOT EDIT.

package metadata

import (
	"testing"

	"github.com/stretchr/testify/assert"
)

func TestResourceBuilder(t *testing.T) {
	for _, tt := range []string{"default", "all_set", "none_set"} {
		t.Run(tt, func(t *testing.T) {
			cfg := loadResourceAttributesConfig(t, tt)
			rb := NewResourceBuilder(cfg)
			rb.SetK8sNamespaceName("k8s.namespace.name-val")
			rb.SetK8sPodName("k8s.pod.name-val")
			rb.SetK8sPodUID("k8s.pod.uid-val")
			rb.SetK8sReplicasetName("k8s.replicaset.name-val")
			rb.SetK8sReplicasetUID("k8s.replicaset.uid-val")

			res := rb.Emit()
			assert.Equal(t, 0, rb.Emit().Attributes().Len()) // Second call should return empty Resource

			switch tt {
			case "default":
				assert.Equal(t, 5, res.Attributes().Len())
			case "all_set":
				assert.Equal(t, 5, res.Attributes().Len())
			case "none_set":
				assert.Equal(t, 0, res.Attributes().Len())
				return
			default:
				assert.Failf(t, "unexpected test case: %s", tt)
			}
			k8sNamespaceNameAttrVal, ok := res.Attributes().Get("k8s.namespace.name")
			assert.True(t, ok)
			if ok {
				assert.Equal(t, "k8s.namespace.name-val", k8sNamespaceNameAttrVal.Str())
			}
			k8sPodNameAttrVal, ok := res.Attributes().Get("k8s.pod.name")
			assert.True(t, ok)
			if ok {
				assert.Equal(t, "k8s.pod.name-val", k8sPodNameAttrVal.Str())
			}
			k8sPodUIDAttrVal, ok := res.Attributes().Get("k8s.pod.uid")
			assert.True(t, ok)
			if ok {
				assert.Equal(t, "k8s.pod.uid-val", k8sPodUIDAttrVal.Str())
			}
			k8sReplicasetNameAttrVal, ok := res.Attributes().Get("k8s.replicaset.name")
			assert.True(t, ok)
			if ok {
				assert.Equal(t, "k8s.replicaset.name-val", k8sReplicasetNameAttrVal.Str())
			}
			k8sReplicasetUIDAttrVal, ok := res.Attributes().Get("k8s.replicaset.uid")
			assert.True(t, ok)
			if ok {
				assert.Equal(t, "k8s.replicaset.uid-val", k8sReplicasetUIDAttrVal.Str())
			}
		})
	}
}
