opentofu/internal/backend/init/init_test.go
Martin Atkins 73dda868cc Move backend/ to internal/backend/
This is part of a general effort to move all of Terraform's non-library
package surface under internal in order to reinforce that these are for
internal use within Terraform only.

If you were previously importing packages under this prefix into an
external codebase, you could pin to an earlier release tag as an interim
solution until you've make a plan to achieve the same functionality some
other way.
2021-05-17 14:09:07 -07:00

45 lines
962 B
Go

package init
import (
"reflect"
"testing"
)
func TestInit_backend(t *testing.T) {
// Initialize the backends map
Init(nil)
backends := []struct {
Name string
Type string
}{
{"local", "*local.Local"},
{"remote", "*remote.Remote"},
{"azurerm", "*azure.Backend"},
{"consul", "*consul.Backend"},
{"cos", "*cos.Backend"},
{"etcdv3", "*etcd.Backend"},
{"gcs", "*gcs.Backend"},
{"inmem", "*inmem.Backend"},
{"manta", "*manta.Backend"},
{"pg", "*pg.Backend"},
{"s3", "*s3.Backend"},
{"swift", "*swift.Backend"},
{"azure", "init.deprecatedBackendShim"},
}
// Make sure we get the requested backend
for _, b := range backends {
t.Run(b.Name, func(t *testing.T) {
f := Backend(b.Name)
if f == nil {
t.Fatalf("backend %q is not present; should be", b.Name)
}
bType := reflect.TypeOf(f()).String()
if bType != b.Type {
t.Fatalf("expected backend %q to be %q, got: %q", b.Name, b.Type, bType)
}
})
}
}