2021-02-09 01:03:15 +01:00
|
|
|
package views
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
"testing"
|
|
|
|
|
2021-05-17 21:07:38 +02:00
|
|
|
"github.com/hashicorp/terraform/internal/command/arguments"
|
2021-02-09 01:03:15 +01:00
|
|
|
"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.
|
|
|
|
}
|