Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

121
Vistas
Clarity Terraform testing for checking resource tags

I am new to clarity test tool. I wanted to know whether clarity can be used to check whether tags are added to AWS resources or not.

I wrote the clarity test for tags like below:

Scenario: EC2 should have tag "application"
    Given Terraform
    And a "aws_instance" of type "resource"
    And "our component is <tag-key>"
    When attribute "tags" exists
    Then attribute "tags" matches regex  "tags.*<tag-key>*"

    Examples:
    | tag-key |
    | Name   |
    | application  |

But I got below error:

Feature: EC2 should have encrypted EBS volume attached

  Scenario: EC2 should have tag "application"        # main.feature:3
    Given Terraform                                  # terraform.go:92 -> *Match
    And a "aws_instance" of type "resource"          # terraform.go:279 -> *Match
    And "our component is <tag-key>"                 # clarity_test.go:49 -> noopComment
    Then attribute "tags" exists                     # terraform.go:304 -> *Match
    Then attribute "tags" matches regex  "<tag-key>"

    Examples:
      | tag-key     |
      | Name        |
      | application |

2 scenarios (2 undefined)
10 steps (8 passed, 2 undefined)
1.849441ms

You can implement step definitions for undefined steps with these snippets:

func attributeMatchesRegex(arg1, arg2 string) error {
        return godog.ErrPending
}

func FeatureContext(s *godog.Suite) {
        s.Step(`^attribute "([^"]*)" matches regex  "([^"]*)"$`, attributeMatchesRegex)
}

Any suggestions here would be helpful.

Regards,

TechGirl

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

The documentation on clarity is pretty minimal regrettably and it mentions nothing about how to write a matcher for entries in an attribute of type map. There are also no examples in clarity's own test suite for this kind of matcher.

I could not find a concrete answer to this, but this might work (adjusting your matcher to match the existence of a tag by its name):

Then attribute "tags.<tag-key>" exists
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda