mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-27 09:21:14 -06:00
68 lines
1.1 KiB
Go
68 lines
1.1 KiB
Go
|
package command
|
||
|
|
||
|
import (
|
||
|
"os"
|
||
|
"testing"
|
||
|
|
||
|
"github.com/mitchellh/cli"
|
||
|
)
|
||
|
|
||
|
func TestGet(t *testing.T) {
|
||
|
ui := new(cli.MockUi)
|
||
|
c := &GetCommand{
|
||
|
Meta: Meta{
|
||
|
ContextOpts: testCtxConfig(testProvider()),
|
||
|
Ui: ui,
|
||
|
},
|
||
|
}
|
||
|
|
||
|
args := []string{
|
||
|
testFixturePath("graph"),
|
||
|
}
|
||
|
if code := c.Run(args); code != 0 {
|
||
|
t.Fatalf("bad: \n%s", ui.ErrorWriter.String())
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func TestGet_multipleArgs(t *testing.T) {
|
||
|
ui := new(cli.MockUi)
|
||
|
c := &GetCommand{
|
||
|
Meta: Meta{
|
||
|
ContextOpts: testCtxConfig(testProvider()),
|
||
|
Ui: ui,
|
||
|
},
|
||
|
}
|
||
|
|
||
|
args := []string{
|
||
|
"bad",
|
||
|
"bad",
|
||
|
}
|
||
|
if code := c.Run(args); code != 1 {
|
||
|
t.Fatalf("bad: \n%s", ui.OutputWriter.String())
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func TestGet_noArgs(t *testing.T) {
|
||
|
cwd, err := os.Getwd()
|
||
|
if err != nil {
|
||
|
t.Fatalf("err: %s", err)
|
||
|
}
|
||
|
if err := os.Chdir(testFixturePath("graph")); err != nil {
|
||
|
t.Fatalf("err: %s", err)
|
||
|
}
|
||
|
defer os.Chdir(cwd)
|
||
|
|
||
|
ui := new(cli.MockUi)
|
||
|
c := &GraphCommand{
|
||
|
Meta: Meta{
|
||
|
ContextOpts: testCtxConfig(testProvider()),
|
||
|
Ui: ui,
|
||
|
},
|
||
|
}
|
||
|
|
||
|
args := []string{}
|
||
|
if code := c.Run(args); code != 0 {
|
||
|
t.Fatalf("bad: \n%s", ui.ErrorWriter.String())
|
||
|
}
|
||
|
}
|