Skip to content

Commit

Permalink
[cmd/builder] Improve TestVersioning
Browse files Browse the repository at this point in the history
  • Loading branch information
mx-psi committed Apr 19, 2024
1 parent dc48d0e commit 456ae08
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 456ae08

Please sign in to comment.