2018-10-16 12:38:32 +00:00
|
|
|
package gonextcloud
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/types"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
groupFoldersTests = []struct {
|
|
|
|
string
|
|
|
|
test
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
"TestGroupFoldersCreate",
|
|
|
|
func(t *testing.T) {
|
|
|
|
// Recreate client
|
|
|
|
var err error
|
2018-10-21 12:53:12 +00:00
|
|
|
groupID, err = c.GroupFolders.Create("API")
|
2018-10-16 12:38:32 +00:00
|
|
|
assert.NoError(t, err)
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"TestGroupFoldersList",
|
|
|
|
func(t *testing.T) {
|
2018-10-21 12:53:12 +00:00
|
|
|
gfs, err := c.GroupFolders.List()
|
2018-10-16 12:38:32 +00:00
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotNil(t, gfs[groupID])
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"TestGroupFolders",
|
|
|
|
func(t *testing.T) {
|
2018-10-21 12:53:12 +00:00
|
|
|
gf, err := c.GroupFolders.Get(groupID)
|
2018-10-16 12:38:32 +00:00
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotNil(t, gf)
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"TestGroupFolderRename",
|
|
|
|
func(t *testing.T) {
|
2018-10-21 12:53:12 +00:00
|
|
|
err := c.GroupFolders.Rename(groupID, "API_Renamed")
|
2018-10-16 12:38:32 +00:00
|
|
|
assert.NoError(t, err)
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"TestGroupFoldersAddGroup",
|
|
|
|
func(t *testing.T) {
|
2018-10-21 12:53:12 +00:00
|
|
|
err := c.GroupFolders.AddGroup(groupID, "admin")
|
2018-10-16 12:38:32 +00:00
|
|
|
assert.NoError(t, err)
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"TestGroupFoldersSetGroupPermissions",
|
|
|
|
func(t *testing.T) {
|
2018-10-21 12:53:12 +00:00
|
|
|
err := c.GroupFolders.SetGroupPermissions(groupID, "admin", types.ReadPermission)
|
2018-10-16 12:38:32 +00:00
|
|
|
assert.NoError(t, err)
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"TestGroupFoldersSetQuota",
|
|
|
|
func(t *testing.T) {
|
2018-10-21 12:53:12 +00:00
|
|
|
err := c.GroupFolders.SetQuota(groupID, 100)
|
2018-10-16 12:38:32 +00:00
|
|
|
assert.NoError(t, err)
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"TestGroupFolderRemoveGroup",
|
|
|
|
func(t *testing.T) {
|
2018-10-21 12:53:12 +00:00
|
|
|
err := c.GroupFolders.RemoveGroup(groupID, "admin")
|
2018-10-16 12:38:32 +00:00
|
|
|
assert.NoError(t, err)
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestGroupFolders(t *testing.T) {
|
|
|
|
c = nil
|
|
|
|
if err := initClient(); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
for _, tt := range groupFoldersTests {
|
|
|
|
t.Run(tt.string, tt.test)
|
|
|
|
}
|
|
|
|
}
|