From dd7c020cf594a7bead50d7bcfc2f9f27df797946 Mon Sep 17 00:00:00 2001 From: Adphi Date: Tue, 16 Oct 2018 12:00:11 +0200 Subject: [PATCH] Fix TestUserCreateWithoutPassword --- gonextcloud_test.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/gonextcloud_test.go b/gonextcloud_test.go index 15f01e2..05d64d4 100644 --- a/gonextcloud_test.go +++ b/gonextcloud_test.go @@ -1,15 +1,19 @@ package gonextcloud import ( + "fmt" "github.com/stretchr/testify/assert" "gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/types" "gopkg.in/yaml.v2" "io/ioutil" + "math/rand" "net/http" "net/url" "os" + "strconv" "strings" "testing" + "time" ) type Config struct { @@ -551,9 +555,12 @@ func TestUserCreateWithoutPassword(t *testing.T) { if err := initClient(); err != nil { 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) - err = c.UserDelete(config.NotExistingUser) + err = c.UserDelete(n) assert.NoError(t, err) }