summaryrefslogtreecommitdiffstats
path: root/api/file_test.go
diff options
context:
space:
mode:
authorJoramWilander <jwawilander@gmail.com>2015-07-21 19:21:05 -0400
committerJoramWilander <jwawilander@gmail.com>2015-07-21 19:23:00 -0400
commitb821d23ed71c89b14aa294debcf390057de27b37 (patch)
tree10b0da76d799d952f32d058550fa5cfb5fda7422 /api/file_test.go
parent39abf24708870cec71a84c01063e647b859b2b67 (diff)
downloadchat-b821d23ed71c89b14aa294debcf390057de27b37.tar.gz
chat-b821d23ed71c89b14aa294debcf390057de27b37.tar.bz2
chat-b821d23ed71c89b14aa294debcf390057de27b37.zip
fixed unit tests to work with team domain changes and update partial url regex for files
Diffstat (limited to 'api/file_test.go')
-rw-r--r--api/file_test.go23
1 files changed, 13 insertions, 10 deletions
diff --git a/api/file_test.go b/api/file_test.go
index 3f414d768..a708e9bb1 100644
--- a/api/file_test.go
+++ b/api/file_test.go
@@ -5,6 +5,7 @@ package api
import (
"bytes"
+ l4g "code.google.com/p/log4go"
"fmt"
"github.com/goamz/goamz/aws"
"github.com/goamz/goamz/s3"
@@ -197,8 +198,9 @@ func TestGetFile(t *testing.T) {
// wait a bit for files to ready
time.Sleep(5 * time.Second)
- if _, downErr := Client.GetFile(filenames[0], true); downErr != nil {
- t.Fatal("file get failed")
+ l4g.Debug(filenames)
+ if _, downErr := Client.GetFile(filenames[0], false); downErr != nil {
+ t.Fatal(downErr)
}
team2 := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN}
@@ -217,35 +219,35 @@ func TestGetFile(t *testing.T) {
Client.LoginByEmail(team2.Name, user2.Email, "pwd")
- if _, downErr := Client.GetFile(filenames[0]+"?d="+url.QueryEscape(data)+"&h="+url.QueryEscape(hash)+"&t="+team.Id, true); downErr != nil {
+ if _, downErr := Client.GetFile(filenames[0]+"?d="+url.QueryEscape(data)+"&h="+url.QueryEscape(hash)+"&t="+team.Id, false); downErr != nil {
t.Fatal(downErr)
}
- if _, downErr := Client.GetFile(filenames[0]+"?d="+url.QueryEscape(data)+"&h="+url.QueryEscape(hash), true); downErr == nil {
+ if _, downErr := Client.GetFile(filenames[0]+"?d="+url.QueryEscape(data)+"&h="+url.QueryEscape(hash), false); downErr == nil {
t.Fatal("Should have errored - missing team id")
}
- if _, downErr := Client.GetFile(filenames[0]+"?d="+url.QueryEscape(data)+"&h="+url.QueryEscape(hash)+"&t=junk", true); downErr == nil {
+ if _, downErr := Client.GetFile(filenames[0]+"?d="+url.QueryEscape(data)+"&h="+url.QueryEscape(hash)+"&t=junk", false); downErr == nil {
t.Fatal("Should have errored - bad team id")
}
- if _, downErr := Client.GetFile(filenames[0]+"?d="+url.QueryEscape(data)+"&h="+url.QueryEscape(hash)+"&t=12345678901234567890123456", true); downErr == nil {
+ if _, downErr := Client.GetFile(filenames[0]+"?d="+url.QueryEscape(data)+"&h="+url.QueryEscape(hash)+"&t=12345678901234567890123456", false); downErr == nil {
t.Fatal("Should have errored - bad team id")
}
- if _, downErr := Client.GetFile(filenames[0]+"?d="+url.QueryEscape(data)+"&t="+team.Id, true); downErr == nil {
+ if _, downErr := Client.GetFile(filenames[0]+"?d="+url.QueryEscape(data)+"&t="+team.Id, false); downErr == nil {
t.Fatal("Should have errored - missing hash")
}
- if _, downErr := Client.GetFile(filenames[0]+"?d="+url.QueryEscape(data)+"&h=junk&t="+team.Id, true); downErr == nil {
+ if _, downErr := Client.GetFile(filenames[0]+"?d="+url.QueryEscape(data)+"&h=junk&t="+team.Id, false); downErr == nil {
t.Fatal("Should have errored - bad hash")
}
- if _, downErr := Client.GetFile(filenames[0]+"?h="+url.QueryEscape(hash)+"&t="+team.Id, true); downErr == nil {
+ if _, downErr := Client.GetFile(filenames[0]+"?h="+url.QueryEscape(hash)+"&t="+team.Id, false); downErr == nil {
t.Fatal("Should have errored - missing data")
}
- if _, downErr := Client.GetFile(filenames[0]+"?d=junk&h="+url.QueryEscape(hash)+"&t="+team.Id, true); downErr == nil {
+ if _, downErr := Client.GetFile(filenames[0]+"?d=junk&h="+url.QueryEscape(hash)+"&t="+team.Id, false); downErr == nil {
t.Fatal("Should have errored - bad data")
}
@@ -429,6 +431,7 @@ func TestGetPublicLink(t *testing.T) {
t.Fatal(err)
}
} else {
+ l4g.Debug(resp.Data.(*model.FileUploadResponse).Filenames[0])
filenames := strings.Split(resp.Data.(*model.FileUploadResponse).Filenames[0], "/")
filename := filenames[len(filenames)-2] + "/" + filenames[len(filenames)-1]
fileId := strings.Split(filename, ".")[0]