// Run once when the suite starts running func (s *RadosDriverSuite) SetUpSuite(c *C) { if err := setting.SetConfig("../../conf/containerops.conf"); err != nil { c.Assert(err, IsNil) } radosDriver, err := s.driver.New() c.Assert(err, IsNil) s.driver = radosDriver.(*radosdesc) c.Log("test bucket started") }
func Test_ossdel(t *testing.T) { path := "oss_test.go" err := setting.SetConfig(testconf) o := new(ossdesc) err = o.Delete(path) if err != nil { t.Error(err) return } }
func Test_ossgetfileinfo(t *testing.T) { path := "oss_test.go" err := setting.SetConfig(testconf) o := new(ossdesc) err = o.Get(path) if err != nil { t.Error(err) return } }
func Test_ossdownload(t *testing.T) { path := "oss_test.go" err := setting.SetConfig(testconf) o := new(ossdesc) err = o.Download(path, "/root/gopath/chunkserver/downloadtest") if err != nil { t.Error(err) return } }
func Test_osssave(t *testing.T) { err := setting.SetConfig(testconf) file := "oss_test.go" o := new(ossdesc) _, err = o.Save(file) if err != nil { t.Error(err) return } }
func Test_amazons3save(t *testing.T) { var err error var url string if err = setting.SetConfig(testconf); err != nil { t.Error(err) } file := "amazons3_test.go" s := new(s3desc) url, err = s.Save(file) if err != nil { t.Error(err) } t.Log(url) }
// Unit Test for gcs func TestGcssave(t *testing.T) { file, err := newTestFile(t) if err != nil { t.Error(err) } err = setting.SetConfig(testconf) if err != nil { t.Error(err) } g := new(gcsdesc) retUrl, err := g.Save(upFileName) if err != nil { t.Error(err) } resp, err := http.Get(retUrl) if err != nil { t.Error(err) } defer resp.Body.Close() // Open file for writing nFile, err := os.Create(downFileName) if err != nil { t.Error(err) } // Use io.Copy to copy a file from URL to a locald disk _, err = io.Copy(nFile, resp.Body) if err != nil { t.Error(err) } buf, err := ioutil.ReadFile(downFileName) if err != nil { t.Error(err) } file.Close() isEqual := strings.EqualFold(fileContent, string(buf)) if !isEqual { t.Fatalf("Testing fail, content of uploadFile is not the same as the content of downloadFile") } }
func Test_aliyunsave(t *testing.T) { var err error var url string if err = setting.SetConfig(testconf); err != nil { t.Error(err) } file := "aliyun_test.go" a := new(aliyundesc) url, err = a.Save(file) if err != nil { t.Error(err) } _, err = http.Get(url) if err != nil { t.Error(err) } }
func Test_qiniusave(t *testing.T) { var err error var url string if err = setting.SetConfig(testconf); err != nil { t.Error(err) } file := "qiniu_test.go" q := new(qiniudesc) url, err = q.Save(file) if err != nil { t.Error(err) } _, err = http.Get(url) if err != nil { t.Error(err) } }
func Test_qcloudsave(t *testing.T) { err := setting.SetConfig(testconf) if err != nil { t.Error(err) } file := "qcloud_test.go" q := new(qclouddesc) url, err := q.Save(file) if err != nil { t.Fatal(err.Error()) } t.Log(url) _, err = http.Get(url) if err != nil { t.Error(err) } }
func main() { if err := setting.SetConfig("conf/containerops.conf"); err != nil { fmt.Printf("Read config failed: %v\n", err.Error()) return } //if read middleware config failed, register function of middleware will be skipped setting.GetConfFromJSON("conf/config.json") app := cli.NewApp() app.Name = setting.AppName app.Usage = setting.Usage app.Version = setting.Version app.Author = setting.Author app.Email = setting.Email app.Commands = []cli.Command{ cmd.CmdWeb, } app.Flags = append(app.Flags, []cli.Flag{}...) app.Run(os.Args) }