Skip to content

Commit

Permalink
[cmd/builder] Improve TestVersioning (#10000)
Browse files Browse the repository at this point in the history
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description

Improves `TestVersioning` added on #9897.

The configurations were not what one would usually find, since when
running the builder we do some validation and setup.
This makes it closer to the real case.

In the process I removed the 'invalid' cases, since these error out
today already
  • Loading branch information
mx-psi committed Apr 19, 2024
1 parent 4a58092 commit 0aa9b10
Showing 1 changed file with 7 additions and 52 deletions.
59 changes: 7 additions & 52 deletions cmd/builder/internal/builder/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,51 +105,19 @@ func TestVersioning(t *testing.T) {
},
expectedErr: nil,
},
{
description: "invalid collector version",
cfgBuilder: func() Config {
cfg := NewDefaultConfig()
cfg.Distribution.OtelColVersion = "invalid"
return cfg
},
expectedErr: ErrVersionMismatch,
},
{
description: "invalid collector version without strict mode, only generate",
cfgBuilder: func() Config {
cfg := NewDefaultConfig()
cfg.Distribution.OtelColVersion = "invalid"
cfg.SkipGetModules = true
cfg.SkipCompilation = true
cfg.SkipStrictVersioning = true
return cfg
},
expectedErr: nil,
},
{
description: "invalid collector version without strict mode",
cfgBuilder: func() Config {
cfg := NewDefaultConfig()
cfg.Distribution.OtelColVersion = "invalid"
cfg.SkipStrictVersioning = true
return cfg
},
expectedErr: errGoGetFailed,
},
{
description: "old component version",
cfgBuilder: func() Config {
cfg := NewDefaultConfig()
cfg.Distribution.Go = "go"
cfg.Exporters = []Module{
{
Import: "go.opentelemetry.io/collector/receiver/otlpreceiver",
GoMod: "go.opentelemetry.io/collector v0.96.0",
GoMod: "go.opentelemetry.io/collector/exporter/otlpexporter v0.96.0",
},
}
return cfg
},
expectedErr: ErrVersionMismatch,
expectedErr: nil,
},
{
description: "old component version without strict mode",
Expand All @@ -159,33 +127,20 @@ func TestVersioning(t *testing.T) {
cfg.SkipStrictVersioning = true
cfg.Exporters = []Module{
{
Import: "go.opentelemetry.io/collector/receiver/otlpreceiver",
GoMod: "go.opentelemetry.io/collector v0.96.0",
},
}
return cfg
},
expectedErr: errCompileFailed,
},
{
description: "invalid component version",
cfgBuilder: func() Config {
cfg := NewDefaultConfig()
cfg.Distribution.Go = "go"
cfg.Exporters = []Module{
{
Import: "go.opentelemetry.io/collector/receiver/otlpreceiver",
GoMod: "go.opentelemetry.io/collector invalid",
GoMod: "go.opentelemetry.io/collector/exporter/otlpexporter v0.96.0",
},
}
return cfg
},
expectedErr: errGoGetFailed,
expectedErr: nil,
},
}
for _, tc := range tests {
t.Run(tc.description, func(t *testing.T) {
cfg := tc.cfgBuilder()
require.NoError(t, cfg.SetRequireOtelColModule())
require.NoError(t, cfg.Validate())
require.NoError(t, cfg.ParseModules())
err := GenerateAndCompile(cfg)
require.ErrorIs(t, err, tc.expectedErr)
})
Expand Down

0 comments on commit 0aa9b10

Please sign in to comment.