Fix TestUserCreateWithoutPassword

This commit is contained in:
Adphi 2018-10-16 12:00:11 +02:00
parent f388c31259
commit dd7c020cf5

View File

@ -1,15 +1,19 @@
package gonextcloud package gonextcloud
import ( import (
"fmt"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/types" "gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/types"
"gopkg.in/yaml.v2" "gopkg.in/yaml.v2"
"io/ioutil" "io/ioutil"
"math/rand"
"net/http" "net/http"
"net/url" "net/url"
"os" "os"
"strconv"
"strings" "strings"
"testing" "testing"
"time"
) )
type Config struct { type Config struct {
@ -551,9 +555,12 @@ func TestUserCreateWithoutPassword(t *testing.T) {
if err := initClient(); err != nil { if err := initClient(); err != nil {
t.Fatal(err) t.Fatal(err)
} }
err := c.UserCreateWithoutPassword(config.NotExistingUser, config.Email, strings.Title(config.NotExistingUser)) // Nextcloud does not seems to like recreating a deleted user
rand.Seed(time.Now().Unix())
n := fmt.Sprintf("%s-%s", config.NotExistingUser, strconv.Itoa(rand.Int()))
err := c.UserCreateWithoutPassword(n, config.Email, strings.Title(config.NotExistingUser))
assert.NoError(t, err) assert.NoError(t, err)
err = c.UserDelete(config.NotExistingUser) err = c.UserDelete(n)
assert.NoError(t, err) assert.NoError(t, err)
} }