photoprism/internal/entity/auth_client_add_test.go
2023-12-21 16:00:28 +01:00

33 lines
633 B
Go

package entity
import (
"testing"
"github.com/photoprism/photoprism/internal/form"
"github.com/stretchr/testify/assert"
)
func Test_AddClient(t *testing.T) {
t.Run("Success", func(t *testing.T) {
m := form.Client{ClientName: "test", AuthMethod: "basic", AuthScope: "all"}
c, err := AddClient(m)
if err != nil {
t.Fatal(err)
}
assert.Equal(t, "test", c.ClientName)
})
t.Run("ClientNameEmpty", func(t *testing.T) {
m := form.Client{ClientName: "", AuthMethod: "basic", AuthScope: "all"}
c, err := AddClient(m)
if err == nil {
t.Fatal("error expected")
}
assert.Equal(t, "", c.ClientName)
})
}