mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-28 01:41:48 -06:00
40 lines
787 B
Go
40 lines
787 B
Go
// Copyright (c) HashiCorp, Inc.
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
package command
|
|
|
|
import (
|
|
"os"
|
|
"reflect"
|
|
"testing"
|
|
|
|
"github.com/mitchellh/cli"
|
|
"github.com/posener/complete"
|
|
)
|
|
|
|
func TestMetaCompletePredictWorkspaceName(t *testing.T) {
|
|
// Create a temporary working directory that is empty
|
|
td := t.TempDir()
|
|
os.MkdirAll(td, 0755)
|
|
defer testChdir(t, td)()
|
|
|
|
// make sure a vars file doesn't interfere
|
|
err := os.WriteFile(DefaultVarsFilename, nil, 0644)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
ui := new(cli.MockUi)
|
|
meta := &Meta{Ui: ui}
|
|
|
|
predictor := meta.completePredictWorkspaceName()
|
|
|
|
got := predictor.Predict(complete.Args{
|
|
Last: "",
|
|
})
|
|
want := []string{"default"}
|
|
if !reflect.DeepEqual(got, want) {
|
|
t.Errorf("wrong result\ngot: %#v\nwant: %#v", got, want)
|
|
}
|
|
}
|