mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-30 10:47:14 -06:00
7f78342953
This is just a prototype to gather some feedback in our ongoing research on integration testing of Terraform modules. The hope is that by having a command integrated into Terraform itself it'll be easier for interested module authors to give it a try, and also easier for us to iterate quickly based on feedback without having to coordinate across multiple codebases. Everything about this is subject to change even in future patch releases. Since it's a CLI command rather than a configuration language feature it's not using the language experiments mechanism, but generates a warning similar to the one language experiments generate in order to be clear that backward compatibility is not guaranteed.
33 lines
890 B
Go
33 lines
890 B
Go
package views
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/hashicorp/terraform/command/arguments"
|
|
"github.com/hashicorp/terraform/internal/moduletest"
|
|
"github.com/hashicorp/terraform/internal/terminal"
|
|
)
|
|
|
|
func TestTest(t *testing.T) {
|
|
streams, close := terminal.StreamsForTesting(t)
|
|
baseView := NewView(streams)
|
|
view := NewTest(baseView, arguments.TestOutput{
|
|
JUnitXMLFile: "",
|
|
})
|
|
|
|
results := map[string]*moduletest.Suite{}
|
|
view.Results(results)
|
|
|
|
output := close(t)
|
|
gotOutput := strings.TrimSpace(output.All())
|
|
wantOutput := `No tests defined. This module doesn't have any test suites to run.`
|
|
if gotOutput != wantOutput {
|
|
t.Errorf("wrong output\ngot:\n%s\nwant:\n%s", gotOutput, wantOutput)
|
|
}
|
|
|
|
// TODO: Test more at this layer. For now, the main UI output tests for
|
|
// the "terraform test" command are in the command package as part of
|
|
// the overall command tests.
|
|
}
|