summaryrefslogtreecommitdiffstats
path: root/test/folders_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'test/folders_test.go')
-rw-r--r--test/folders_test.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/folders_test.go b/test/folders_test.go
index 42db7c2..065e3e3 100644
--- a/test/folders_test.go
+++ b/test/folders_test.go
@@ -27,6 +27,8 @@ import (
)
func TestFolders(t *testing.T) {
+ /*init: check there is no folder*/
+ t.Log("check there is no folder")
var cfgArray []xsapiv1.FolderConfig
assert.Nil(t, HTTPCli.Get("/folders", &cfgArray))
assert.Equal(t, len(cfgArray), 0)
@@ -41,8 +43,10 @@ func TestFolders(t *testing.T) {
},
}
var cfg xsapiv1.FolderConfig
+ t.Logf("create folder: \n%v", fPrj)
assert.Nil(t, HTTPCli.Post("/folders", fPrj, &cfg))
assert.NotNil(t, cfg)
+ t.Logf("result folder: \n%v", cfg)
isCfgPrjMatch := func(fPrj xsapiv1.FolderConfig, cfg xsapiv1.FolderConfig) {
re := regexp.MustCompile("^[0-9a-z]+-[0-9a-z]+-[0-9a-z]+-[0-9a-z]+-[0-9a-z]+$")
@@ -70,18 +74,23 @@ func TestFolders(t *testing.T) {
/*create/delete folders*/
var cfgArrayBis []xsapiv1.FolderConfig
assert.Nil(t, HTTPCli.Post("/folders", fPrj, &cfg))
+ t.Logf("create folder with id=%v", cfg.ID)
assert.Nil(t, HTTPCli.Post("/folders", fPrj, &cfg))
+ t.Logf("create folder with id=%v", cfg.ID)
assert.Nil(t, HTTPCli.Get("/folders", &cfgArray))
assert.Equal(t, len(cfgArray), 3)
assert.Nil(t, HTTPCli.Delete("/folders/"+cfgArray[1].ID, &cfg))
+ t.Logf("delete folder with id=%v", cfg.ID)
assert.Equal(t, cfg, cfgArray[1])
assert.Nil(t, HTTPCli.Get("/folders", &cfgArrayBis))
assert.Equal(t, len(cfgArrayBis), 2)
assert.Nil(t, HTTPCli.Delete("/folders/"+cfgArray[0].ID, &cfg))
+ t.Logf("delete folder with id=%v", cfg.ID)
assert.Equal(t, cfg, cfgArray[0])
assert.Nil(t, HTTPCli.Get("/folders", &cfgArrayBis))
assert.Equal(t, len(cfgArrayBis), 1)
assert.Nil(t, HTTPCli.Delete("/folders/"+cfgArray[2].ID, &cfg))
+ t.Logf("delete folder with id=%v", cfg.ID)
assert.Equal(t, cfg, cfgArray[2])
assert.Nil(t, HTTPCli.Get("/folders", &cfgArrayBis))
assert.Equal(t, len(cfgArrayBis), 0)
@@ -100,16 +109,19 @@ func TestFoldersEmptyValues(t *testing.T) {
var cfg xsapiv1.FolderConfig
/*ServerPath is empty*/
assert.NotNil(t, HTTPCli.Post("/folders", fPrj, &cfg))
+ t.Logf("error while creating folder with empty serverpath \n%v", fPrj)
fPrj.DataPathMap.ServerPath = logDir + "sameserverpath"
fPrj.ClientPath = ""
/*ClientPath is Empty*/
assert.NotNil(t, HTTPCli.Post("/folders", fPrj, &cfg))
+ t.Logf("error while creating folder with empty clientpath \n%v", fPrj)
fPrj.ClientPath = "logDir"
fPrj.Type = ""
/*Type is empty*/
assert.NotNil(t, HTTPCli.Post("/folders", fPrj, &cfg))
+ t.Logf("error while creating folder with empty type \n%v", fPrj)
var cfgArray []xsapiv1.FolderConfig
assert.Nil(t, HTTPCli.Get("/folders", &cfgArray))
@@ -130,6 +142,7 @@ func TestFoldersPathMapConfig(t *testing.T) {
var cfg xsapiv1.FolderConfig
/*file not present*/
assert.NotNil(t, HTTPCli.Post("/folders", fPrj, &cfg))
+ t.Logf("error while creating folder with no checkfile \n%v", fPrj)
var checkFileClient = fPrj.ClientPath + "/checkfile"
var checkFileServer = fPrj.DataPathMap.ServerPath + "/checkfile"
@@ -147,14 +160,17 @@ func TestFoldersPathMapConfig(t *testing.T) {
}
/*file content differ*/
assert.NotNil(t, HTTPCli.Post("/folders", fPrj, &cfg))
+ t.Logf("error while creating folder with different checkfiles \n%v", fPrj)
/*write same message*/
if _, err := file.WriteString(fPrj.DataPathMap.CheckContent); err != nil {
t.Log(err)
}
assert.Nil(t, HTTPCli.Post("/folders", fPrj, &cfg))
+ t.Logf("create folder with same checkfiles \n%v", fPrj)
/*check server msg: ServerUID needed*/
+ t.Logf("check server msg")
var APIcfg xsapiv1.APIConfig
assert.Nil(t, HTTPCli.Get("/config", &APIcfg))
msg := "Pathmap checked message written by xds-server ID: " + APIcfg.ServerUID + "\n"