2018-07-04 17:24:49 +02:00
|
|
|
package init
|
|
|
|
|
|
|
|
import (
|
|
|
|
"reflect"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestInit_backend(t *testing.T) {
|
|
|
|
// Initialize the backends map
|
|
|
|
Init(nil)
|
|
|
|
|
|
|
|
backends := []struct {
|
|
|
|
Name string
|
|
|
|
Type string
|
|
|
|
}{
|
2018-10-17 04:48:28 +02:00
|
|
|
{"local", "*local.Local"},
|
2018-10-31 16:45:03 +01:00
|
|
|
{"remote", "*remote.Remote"},
|
2018-10-17 04:48:28 +02:00
|
|
|
{"atlas", "*atlas.Backend"},
|
|
|
|
{"azurerm", "*azure.Backend"},
|
|
|
|
{"consul", "*consul.Backend"},
|
|
|
|
{"etcdv3", "*etcd.Backend"},
|
|
|
|
{"gcs", "*gcs.Backend"},
|
|
|
|
{"inmem", "*inmem.Backend"},
|
|
|
|
{"manta", "*manta.Backend"},
|
2018-10-13 02:00:22 +02:00
|
|
|
{"pg", "*pg.Backend"},
|
2018-10-17 04:48:28 +02:00
|
|
|
{"s3", "*s3.Backend"},
|
|
|
|
{"swift", "*swift.Backend"},
|
|
|
|
{"azure", "init.deprecatedBackendShim"},
|
2018-07-04 17:24:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Make sure we get the requested backend
|
|
|
|
for _, b := range backends {
|
2018-10-17 04:48:28 +02:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
})
|
2018-07-04 17:24:49 +02:00
|
|
|
}
|
|
|
|
}
|