Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

122
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda