PKGBUILD/pkg/storage/db/db_test.go

39 lines
890 B
Go

package db
import (
"net/url"
"testing"
"github.com/stretchr/testify/require"
)
func TestNew(t *testing.T) {
require := require.New(t)
validStorageEndpoints := []string{
"postgres://flucky:flucky@markus-pc.trier.cryptic.systems/postgres?sslmode=disable",
}
unsupportedStorageEndpoints := []string{
"html://flucky.cryptic.systems",
"oracle://flucky:flucky@example.com/postgres",
}
for _, validStorageEndpoint := range validStorageEndpoints {
storageEndpointURL, err := url.Parse(validStorageEndpoint)
require.Nil(err)
dbo, err := New(storageEndpointURL)
require.Nil(err)
err = dbo.Close()
require.Nil(err)
}
for _, unsupportedStorageEndpoint := range unsupportedStorageEndpoints {
storageEndpointURL, err := url.Parse(unsupportedStorageEndpoint)
require.Nil(err)
_, err = New(storageEndpointURL)
require.Equal(errorUnsupportedDatabase, err)
}
}