2020-03-23 22:41:10 -07:00
|
|
|
// Copyright The OpenTelemetry Authors
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
2021-01-13 14:07:44 -08:00
|
|
|
package basic
|
2020-03-20 08:58:32 -07:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
|
2021-02-18 12:59:37 -05:00
|
|
|
"go.opentelemetry.io/otel/attribute"
|
2020-03-20 08:58:32 -07:00
|
|
|
"go.opentelemetry.io/otel/sdk/resource"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestWithResource(t *testing.T) {
|
2021-06-08 12:46:42 -04:00
|
|
|
r := resource.NewSchemaless(attribute.String("A", "a"))
|
2020-03-20 08:58:32 -07:00
|
|
|
|
2021-05-14 22:28:28 +02:00
|
|
|
c := &config{}
|
|
|
|
WithResource(r).apply(c)
|
2020-04-23 12:10:58 -07:00
|
|
|
assert.Equal(t, r.Equivalent(), c.Resource.Equivalent())
|
2020-03-20 08:58:32 -07:00
|
|
|
|
|
|
|
// Ensure overwriting works.
|
2021-05-14 22:28:28 +02:00
|
|
|
c = &config{Resource: &resource.Resource{}}
|
|
|
|
WithResource(r).apply(c)
|
2020-04-23 12:10:58 -07:00
|
|
|
assert.Equal(t, r.Equivalent(), c.Resource.Equivalent())
|
2020-03-20 08:58:32 -07:00
|
|
|
}
|