You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
882 B

  1. package config_test
  2. import (
  3. "testing"
  4. "github.com/stretchr/testify/assert"
  5. "gerrit.wikimedia.org/r/blubber/config"
  6. )
  7. func TestVersionConfigYAML(t *testing.T) {
  8. cfg, err := config.ReadYAMLConfig([]byte(`---
  9. version: v4
  10. variants:
  11. foo: {}`))
  12. assert.Nil(t, err)
  13. if assert.NoError(t, err) {
  14. assert.Equal(t, "v4", cfg.Version)
  15. }
  16. }
  17. func TestVersionConfigValidation(t *testing.T) {
  18. t.Run("supported version", func(t *testing.T) {
  19. err := config.Validate(config.VersionConfig{
  20. Version: "v4",
  21. })
  22. assert.False(t, config.IsValidationError(err))
  23. })
  24. t.Run("unsupported version", func(t *testing.T) {
  25. err := config.Validate(config.VersionConfig{
  26. Version: "vX",
  27. })
  28. if assert.True(t, config.IsValidationError(err)) {
  29. msg := config.HumanizeValidationError(err)
  30. assert.Equal(t, `version: config version "vX" is unsupported`, msg)
  31. }
  32. })
  33. }