Commit ba43e1dc authored by Adphi's avatar Adphi

wip: fix walk, TODO: find a fix for fileinfo's name

parent 04fe0dc8
Pipeline #1304 failed with stage
in 23 minutes and 49 seconds
......@@ -60,37 +60,37 @@ func NewClient(hostname string) (*Client, error) {
return c, nil
}
//Apps return the Apps client Interface
// Apps return the Apps client Interface
func (c *Client) Apps() types.Apps {
return c.apps
}
//AppsConfig return the AppsConfig client Interface
// AppsConfig return the AppsConfig client Interface
func (c *Client) AppsConfig() types.AppsConfig {
return c.appsConfig
}
//GroupFolders return the GroupFolders client Interface
// GroupFolders return the GroupFolders client Interface
func (c *Client) GroupFolders() types.GroupFolders {
return c.groupFolders
}
//Notifications return the Notifications client Interface
// Notifications return the Notifications client Interface
func (c *Client) Notifications() types.Notifications {
return c.notifications
}
//Shares return the Shares client Interface
// Shares return the Shares client Interface
func (c *Client) Shares() types.Shares {
return c.shares
}
//Users return the Users client Interface
// Users return the Users client Interface
func (c *Client) Users() types.Users {
return c.users
}
//Groups return the Groups client Interface
// Groups return the Groups client Interface
func (c *Client) Groups() types.Groups {
return c.groups
}
......
......@@ -5,4 +5,5 @@ app-name: testapp
share-folder: /Documents
not-existing-user: this-user-should-not-exist
not-existing-group: this-group-should-not-exist
email: $NEXTCLOUD_EMAIL
\ No newline at end of file
not-existing-folder: this-folder-should-not-exist
email: $NEXTCLOUD_EMAIL
......@@ -5,4 +5,5 @@ app-name: testapp
share-folder: /Documents
not-existing-user: this-user-should-not-exist
not-existing-group: this-group-should-not-exist
email: my@mail.com
\ No newline at end of file
not-existing-folder: this-folder-should-not-exist
email: my@mail.com
......@@ -3,13 +3,36 @@ module gitlab.bertha.cloud/partitio/Nextcloud-Partitio/gonextcloud
go 1.12
require (
9fans.net/go v0.0.2 // indirect
github.com/alecthomas/gometalinter v3.0.0+incompatible // indirect
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf // indirect
github.com/davidrjenni/reftools v0.0.0-20190411195930-981bbac422f8 // indirect
github.com/fatih/gomodifytags v0.0.0-20190714141403-b08246536dab // indirect
github.com/fatih/motion v0.0.0-20190527122956-41470362fad4 // indirect
github.com/fatih/structs v0.0.0-20180123065059-ebf56d35bba7
github.com/google/go-querystring v0.0.0-20170111101155-53e6ce116135 // indirect
github.com/google/shlex v0.0.0-20181106134648-c34317bd91bf // indirect
github.com/josharian/impl v0.0.0-20190706034337-76254c7a7314 // indirect
github.com/jstemmer/gotags v1.4.1 // indirect
github.com/kisielk/errcheck v1.2.0 // indirect
github.com/klauspost/asmfmt v1.2.0 // indirect
github.com/koron/iferr v0.0.0-20180615142939-bb332a3b1d91 // indirect
github.com/kr/pty v1.1.8 // indirect
github.com/levigross/grequests v0.0.0-20171009010347-bf9788368aa0
github.com/mdempsky/gocode v0.0.0-20190203001940-7fb65232883f // indirect
github.com/pkg/errors v0.0.0-20181023235946-059132a15dd0
github.com/rogpeppe/godef v1.1.1 // indirect
github.com/sirupsen/logrus v1.4.2
github.com/stretchr/testify v1.2.2
github.com/studio-b12/gowebdav v0.0.0-20190103184047-38f79aeaf1ac
golang.org/x/net v0.0.0-20181129055619-fae4c4e3ad76 // indirect
github.com/zmb3/gogetdoc v0.0.0-20190228002656-b37376c5da6a // indirect
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4 // indirect
golang.org/x/mod v0.1.0 // indirect
golang.org/x/net v0.0.0-20190628185345-da137c7871d7 // indirect
golang.org/x/sys v0.0.0-20190712062909-fae7ac547cb7 // indirect
golang.org/x/text v0.3.2 // indirect
golang.org/x/tools v0.0.0-20190715044752-607ca053a137 // indirect
gopkg.in/alecthomas/kingpin.v3-unstable v3.0.0-20180810215634-df19058c872c // indirect
gopkg.in/yaml.v2 v2.2.1
honnef.co/go/tools v0.0.0-2019.2.1 // indirect
)
This diff is collapsed.
......@@ -25,6 +25,7 @@ type Config struct {
ShareFolder string `yaml:"share-folder"`
NotExistingUser string `yaml:"not-existing-user"`
NotExistingGroup string `yaml:"not-existing-group"`
NotExistingFolder string `yaml:"not-existing-folder"`
Email string `yaml:"email"`
}
......
......@@ -84,9 +84,7 @@ func (wd *webDav) readDirNames(dirname string) ([]string, error) {
}
var names []string
for _, i := range fs {
if i.IsDir() {
names = append(names, i.Name())
}
names = append(names, i.Name())
}
sort.Strings(names)
return names, nil
......
package gonextcloud
import (
"os"
"strings"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"gitlab.bertha.cloud/partitio/Nextcloud-Partitio/gonextcloud/types"
)
var (
dir string
wd types.WebDav
wtests = []struct {
name string
test test
}{
{
name: "CreateFolder",
test: testCreateFolder,
},
{
name: "TestStat",
test: testStat,
},
{
name: "TestWalk",
test: testWalk,
},
{
name: "TestDelete",
test: testDelete,
},
}
)
func TestWebDav(t *testing.T) {
if err := initClient(); err != nil {
t.Fatal(err)
}
if config.NotExistingFolder == "" {
config.NotExistingFolder = "/not-existing-folder"
}
dir = config.NotExistingFolder
wd = c.WebDav()
for _, tt := range wtests {
t.Run(tt.name, tt.test)
}
}
func testCreateFolder(t *testing.T){
err := wd.Mkdir(dir, 0777)
require.NoError(t, err)
}
func testStat(t *testing.T) {
i, err := wd.Stat(dir)
require.NoError(t, err)
// TODO : there is a problem with fileinfo's Name : find a fix
// assert.Equal(t, dir, i.Name())
assert.True(t, i.IsDir())
}
func testWalk(t *testing.T) {
found := false
err := wd.Walk("/", func(path string, info os.FileInfo, err error) error {
path = strings.Trim(path, "/")
assert.NoError(t, err)
if path == dir {
found = true
}
// TODO : there is a problem with fileinfo's Name : find a fix
// p := strings.Split(path, "/")
// assert.Equal(t, p[len(p)-1], info.Name())
return nil
})
assert.NoError(t, err)
assert.True(t, found)
}
func testDelete(t *testing.T) {
err := wd.Remove(dir)
require.NoError(t, err)
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment