Very nice looking tests!

Signed-off-by: Kris Nóva <kris@nivenly.com>
This commit is contained in:
Kris Nóva 2021-02-09 16:00:02 -08:00
parent 3b41c9dd5f
commit c1a45bf8e3
149 changed files with 1241 additions and 443 deletions

View file

@ -5,11 +5,25 @@ import (
"strings"
"testing"
photoprism "github.com/kris-nova/client-go"
"github.com/kris-nova/logger"
sampleapp "github.com/kris-nova/client-go/sample-app"
)
const (
WellKnownUser = "admin"
WellKnownPass = "missy"
BadPassword = "charlie"
WellKnownPhotoID = "pqnzigq351j2fqgn" // This is a photo in the persistent sample app
WellKnownSampleAppConnectionString = "http://localhost:8080"
)
// Client is a pre-authenticated client that can be used
// internally to access the SDK
var Client *photoprism.Client
func TestMain(m *testing.M) {
logger.Level = 4
app := sampleapp.New()
@ -39,6 +53,15 @@ func TestMain(m *testing.M) {
os.Exit(2)
}
// --- [ Client ] ---
client := photoprism.New(WellKnownSampleAppConnectionString)
err = client.Auth(photoprism.NewClientAuthLogin(WellKnownUser, WellKnownPass))
if err != nil {
logger.Critical("Error during testing auth: %v", err)
os.Exit(3)
}
Client = client
// --- [ Tests ] ----
exitCode := m.Run()
if exitCode != 0 {