mirror of
https://github.com/grafana/grafana.git
synced 2025-01-08 23:23:45 -06:00
test(imageupload): add more specific tests
torkels commit will fix this unit test :)
This commit is contained in:
parent
fc8f0721cd
commit
d1a7a23c84
@ -1,7 +1,6 @@
|
||||
package imguploader
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
@ -27,7 +26,12 @@ func TestImageUploaderFactory(t *testing.T) {
|
||||
uploader, err := NewImageUploader()
|
||||
|
||||
So(err, ShouldBeNil)
|
||||
So(reflect.TypeOf(uploader), ShouldEqual, reflect.TypeOf(&S3Uploader{}))
|
||||
original, ok := uploader.(*S3Uploader)
|
||||
|
||||
So(ok, ShouldBeTrue)
|
||||
So(original.accessKey, ShouldEqual, "access_key")
|
||||
So(original.secretKey, ShouldEqual, "secret_key")
|
||||
So(original.bucket, ShouldEqual, "bucket_url")
|
||||
})
|
||||
|
||||
Convey("Webdav uploader", func() {
|
||||
@ -47,7 +51,12 @@ func TestImageUploaderFactory(t *testing.T) {
|
||||
uploader, err := NewImageUploader()
|
||||
|
||||
So(err, ShouldBeNil)
|
||||
So(reflect.TypeOf(uploader), ShouldEqual, reflect.TypeOf(&WebdavUploader{}))
|
||||
original, ok := uploader.(*WebdavUploader)
|
||||
|
||||
So(ok, ShouldBeTrue)
|
||||
So(original.url, ShouldEqual, "webdavUrl")
|
||||
So(original.username, ShouldEqual, "username")
|
||||
So(original.password, ShouldEqual, "password")
|
||||
})
|
||||
})
|
||||
}
|
||||
|
@ -23,7 +23,6 @@ func NewS3Uploader(bucket, accessKey, secretKey string) *S3Uploader {
|
||||
}
|
||||
|
||||
func (u *S3Uploader) Upload(path string) (string, error) {
|
||||
|
||||
s3util.DefaultConfig.AccessKey = u.accessKey
|
||||
s3util.DefaultConfig.SecretKey = u.secretKey
|
||||
|
||||
|
23
pkg/components/imguploader/s3uploader_test.go
Normal file
23
pkg/components/imguploader/s3uploader_test.go
Normal file
@ -0,0 +1,23 @@
|
||||
package imguploader
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
. "github.com/smartystreets/goconvey/convey"
|
||||
)
|
||||
|
||||
func TestUploadToS3(t *testing.T) {
|
||||
SkipConvey("[Integration test] for external_image_store.webdav", t, func() {
|
||||
setting.NewConfigContext(&setting.CommandLineArgs{
|
||||
HomePath: "../../../",
|
||||
})
|
||||
|
||||
s3Uploader, _ := NewImageUploader()
|
||||
|
||||
path, err := s3Uploader.Upload("../../../public/img/logo_transparent_400x.png")
|
||||
|
||||
So(err, ShouldBeNil)
|
||||
So(path, ShouldNotEqual, "")
|
||||
})
|
||||
}
|
@ -9,7 +9,6 @@ import (
|
||||
"path"
|
||||
"time"
|
||||
|
||||
"github.com/grafana/grafana/pkg/log"
|
||||
"github.com/grafana/grafana/pkg/util"
|
||||
)
|
||||
|
||||
@ -20,7 +19,6 @@ type WebdavUploader struct {
|
||||
}
|
||||
|
||||
func (u *WebdavUploader) Upload(pa string) (string, error) {
|
||||
log.Error2("Hej")
|
||||
client := http.Client{Timeout: time.Duration(10 * time.Second)}
|
||||
|
||||
url, _ := url.Parse(u.url)
|
||||
|
Loading…
Reference in New Issue
Block a user