Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden
Status | |
---|---|
Stability | alpha: traces, metrics, logs |
Issues | |
Code Owners | @djaglowski, @atoulme |
The package golden provides utilities for reading and writing files with metrics, traces and logs in YAML format. The package is expected to be used with pkg/pdatatest module.
The easiest way to capture the expected result in a file is golden.WriteMetrics
, golden.WriteTraces
or golden.WriteLogs
.
When writing a new test:
When updating an existing test:
golden.WriteMetrics
, golden.WriteTraces
or golden.WriteLogs
or in the appropriate place.golden.WriteMetrics
, golden.WriteTraces
or golden.WriteLogs
.NOTE: golden.WriteMetrics
will always mark the test as failed. This behavior is
necessary to ensure the function is removed after the golden file is written.
func TestScraper(t *testing.T) {
cfg := createDefaultConfig().(*Config)
require.NoError(t, component.ValidateConfig(cfg))
scraper := newScraper(componenttest.NewNopReceiverCreateSettings(), cfg)
err := scraper.start(context.Background(), componenttest.NewNopHost())
require.NoError(t, err)
actualMetrics, err := scraper.scrape(context.Background())
require.NoError(t, err)
expectedFile := filepath.Join("testdata", "scraper", "expected.yaml")
golden.WriteMetrics(t, expectedFile, actualMetrics) // This line is temporary! TODO remove this!!
expectedMetrics, err := golden.ReadMetrics(expectedFile)
require.NoError(t, err)
require.NoError(t, pmetrictest.CompareMetrics(expectedMetrics, actualMetrics))
}
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.