// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package otel // import "go.opentelemetry.io/otel"

import (
	"testing"

	"github.com/stretchr/testify/assert"

	"go.opentelemetry.io/otel/metric"
	"go.opentelemetry.io/otel/metric/embedded"
	"go.opentelemetry.io/otel/metric/noop"
)

type testMeterProvider struct{ embedded.MeterProvider }

var _ metric.MeterProvider = &testMeterProvider{}

func (*testMeterProvider) Meter(string, ...metric.MeterOption) metric.Meter {
	return noop.NewMeterProvider().Meter("")
}

func TestMultipleGlobalMeterProvider(t *testing.T) {
	p1 := testMeterProvider{}
	p2 := noop.NewMeterProvider()
	SetMeterProvider(&p1)
	SetMeterProvider(p2)

	got := GetMeterProvider()
	assert.Equal(t, p2, got)
}
