Browse Source

Fix webdav/cloud package name

Andrea Fazzi 7 years ago
parent
commit
117e627b12
1 changed files with 36 additions and 18 deletions
  1. 36 18
      compiler/compiler_test.go

+ 36 - 18
compiler/compiler_test.go

@@ -1,11 +1,13 @@
 package compiler
 package compiler
 
 
 import (
 import (
+	"io/ioutil"
 	"testing"
 	"testing"
 
 
+	"github.com/remogatto/cloud"
 	"github.com/remogatto/prettytest"
 	"github.com/remogatto/prettytest"
-	"gogs.carducci-dante.gov.it/andrea.fazzi/karmen/config"
-	"gogs.carducci-dante.gov.it/andrea.fazzi/karmen/webdav"
+
+	"gogs.carducci-dante.gov.it/karmen/core/config"
 )
 )
 
 
 type testSuite struct {
 type testSuite struct {
@@ -14,7 +16,7 @@ type testSuite struct {
 
 
 var (
 var (
 	compiler   *Compiler
 	compiler   *Compiler
-	client     *webdav.Client
+	client     *cloud.Client
 	simpleMain string = `
 	simpleMain string = `
 package main
 package main
 
 
@@ -23,7 +25,7 @@ func main() {
 }
 }
 
 
 `
 `
-	webDAVTemplateProgram string = `
+	cloudTemplateProgram string = `
 package main
 package main
 
 
 import (
 import (
@@ -31,18 +33,18 @@ import (
 	"fmt"
 	"fmt"
 	"text/template"
 	"text/template"
 
 
-	"gogs.carducci-dante.gov.it/andrea.fazzi/karmen/webdav"
+	"github.com/remogatto/cloud"
 )
 )
 
 
 func main() {
 func main() {
 	var (
 	var (
-		WebDAVUrl      = "http://localhost:8082/remote.php/webdav/"
+		WebDAVUrl      = "http://karmen_cloud_test/remote.php/webdav/"
 		WebDavUsername = "admin"
 		WebDavUsername = "admin"
 		WebDAVPassword = "password"
 		WebDAVPassword = "password"
 		data           struct{ Data string }
 		data           struct{ Data string }
 		output         bytes.Buffer
 		output         bytes.Buffer
 	)
 	)
-	client, err := webdav.NewClient(WebDAVUrl, WebDavUsername, WebDAVPassword)
+	client, err := cloud.Dial(WebDAVUrl, WebDavUsername, WebDAVPassword)
 	if err != nil {
 	if err != nil {
 		fmt.Print(err)
 		fmt.Print(err)
 	}
 	}
@@ -83,8 +85,8 @@ func TestRunner(t *testing.T) {
 
 
 func (t *testSuite) BeforeAll() {
 func (t *testSuite) BeforeAll() {
 	var err error
 	var err error
-	compiler = New("http://localhost:8083/compile")
-	client, err = webdav.NewClient(
+	compiler = New("http://localhost:8080/compile")
+	client, err = cloud.Dial(
 		config.WebDAVUrl,
 		config.WebDAVUrl,
 		config.WebDavUsername,
 		config.WebDavUsername,
 		config.WebDAVPassword,
 		config.WebDAVPassword,
@@ -92,6 +94,18 @@ func (t *testSuite) BeforeAll() {
 	if err != nil {
 	if err != nil {
 		panic(err)
 		panic(err)
 	}
 	}
+	if !client.Exists("Templates") {
+		if err := client.Mkdir("Templates"); err != nil {
+			panic(err)
+		}
+	}
+	templateData, err := ioutil.ReadFile("testdata/template.tpl")
+	if err != nil {
+		panic(err)
+	}
+	if err := client.Upload(templateData, "Templates/template.tpl"); err != nil {
+		panic(err)
+	}
 
 
 }
 }
 
 
@@ -99,19 +113,23 @@ func (t *testSuite) TestRunSimpleMain() {
 	program := &Program{simpleMain}
 	program := &Program{simpleMain}
 	result, err := compiler.Run(program)
 	result, err := compiler.Run(program)
 	t.Nil(err)
 	t.Nil(err)
-	t.Equal("Hello World!\n", result.Events[0].Message)
+	if err == nil {
+		t.Equal("Hello World!\n", result.Events[0].Message)
+	}
 }
 }
 
 
-func (t *testSuite) TestWebDAVTemplate() {
-	program := &Program{webDAVTemplateProgram}
+func (t *testSuite) TestCloudTemplate() {
+	program := &Program{cloudTemplateProgram}
 	result, err := compiler.Run(program)
 	result, err := compiler.Run(program)
 	t.Nil(err)
 	t.Nil(err)
-	t.Equal("", result.Errors)
-	if result.Errors == "" {
-		t.Equal("ok", result.Events[0].Message)
-		data, err := client.Download("Test/foo.txt")
-		t.Nil(err)
-		t.Equal("Foo", string(data))
+	if err == nil {
+		t.Equal("", result.Errors)
+		if result.Errors == "" {
+			t.Equal("ok", result.Events[0].Message)
+			data, err := client.Download("Test/foo.txt")
+			t.Nil(err)
+			t.Equal("Foo", string(data))
+		}
 	}
 	}
 
 
 }
 }