Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider Supporting test command JSON messages #96

Open
bflad opened this issue Jul 25, 2023 · 0 comments
Open

Consider Supporting test command JSON messages #96

bflad opened this issue Jul 25, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@bflad
Copy link
Member

bflad commented Jul 25, 2023

Description

Running the upcoming terraform test -json command has specific JSON message types, e.g.

{"@level":"info","@message":"Found 1 file and 1 run block","@module":"terraform.ui","@timestamp":"2023-07-25T10:03:42.974507-04:00","test_abstract":{"tests/passthrough.tftest":["variable_output_passthrough"]},"type":"test_abstract"}
{"@level":"info","@message":"tests/passthrough.tftest... fail","@module":"terraform.ui","@testfile":"tests/passthrough.tftest","@timestamp":"2023-07-25T10:03:42.977420-04:00","test_file":{"path":"tests/passthrough.tftest","status":"fail"},"type":"test_file"}
{"@level":"info","@message":"  \"variable_output_passthrough\"... fail","@module":"terraform.ui","@testfile":"tests/passthrough.tftest","@testrun":"variable_output_passthrough","@timestamp":"2023-07-25T10:03:42.977444-04:00","test_run":{"path":"tests/passthrough.tftest","run":"variable_output_passthrough","status":"fail"},"type":"test_run"}
{"@level":"error","@message":"Error: Test assertion failed","@module":"terraform.ui","@testfile":"tests/passthrough.tftest","@testrun":"variable_output_passthrough","@timestamp":"2023-07-25T10:03:42.977566-04:00","diagnostic":{"severity":"error","summary":"Test assertion failed","detail":"variable was not passed through to output","range":{"filename":"tests/passthrough.tftest","start":{"line":9,"column":21,"byte":123},"end":{"line":9,"column":50,"byte":152}},"snippet":{"context":"run \"variable_output_passthrough\"","code":"    condition     = output.test == \"test value 2\"","start_line":9,"highlight_start_offset":20,"highlight_end_offset":49,"values":[{"traversal":"output.test","statement":"is \"test value\""}]}},"type":"diagnostic"}
{"@level":"info","@message":"Failure! 0 passed, 1 failed.","@module":"terraform.ui","@timestamp":"2023-07-25T10:03:42.980799-04:00","test_summary":{"status":"fail","passed":0,"failed":1,"errored":0,"skipped":0},"type":"test_summary"}

Proposal

Add the following type definitions, similar to Diagnostic message handling:

// "test_abstract":{"tests/passthrough.tftest":["variable_output_passthrough"]}
// Could potentially be defined as type TestAbstract map[string][]string

// "test_file":{"path":"tests/passthrough.tftest","status":"fail"}
type TestFile struct {
  Path string
  Status string // potentially introduce constants?
}

// "test_run":{"path":"tests/passthrough.tftest","run":"variable_output_passthrough","status":"fail"}
type TestRun struct {
  Path string
  Run string
  Status string // potentially introduce constants?
}

// "test_summary":{"status":"fail","passed":0,"failed":1,"errored":0,"skipped":0}
type TestSummary struct {
  Errored int
  Failed int
  Passed int
  Skipped int
  Status string // potentially introduce constants?
}
@bflad bflad added the enhancement New feature or request label Jul 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant