예제 #1
0
func (suite *GraphTestSuite) BenchmarkWrite(t *C) {
	var err error
	var info graph.NodeInfo

	info.ParentId = graph.RootNodeId
	info.Mode = os.FileMode(0755)
	info.Type = "application/json"
	for i := 0; err == nil && i < t.N; i++ {
		info.Name = fmt.Sprint(i)
		_, err = suite.ng.NewNodeWithNodeInfo(info)
	}

	if err != nil {
		panic(err)
	}
}
예제 #2
0
func (suite *ApiTestSuite) TestUpdateNode_renameAndMoveWorksSuccessfully(t *C) {
	folder, err := suite.ng.CreateDirectory(suite.ng.RootNode.Id, "folder 1")
	t.Check(err, IsNil)

	nodeInfo := graph.NodeInfo{
		Name: "file.txt",
		Mode: 0755,
	}
	id, err := suite.createNodeWithSize(suite.ng.RootNode.Id, nodeInfo, 1024)
	t.Check(err, IsNil)

	nodeInfo.Name = "file.pdf"
	nodeInfo.ParentId = folder.Id

	req := suite.request(api.UpdateNode.Build(id), encode(nodeInfo))
	resp, err := suite.client.Do(req)
	t.Check(err, IsNil)
	t.Check(msg(resp), Equals, "")

	t.Check(folder.Children(), HasLen, 1)
	t.Check(folder.Children()[0].Name(), Equals, "file.pdf")
}
예제 #3
0
func (suite *ApiTestSuite) TestUpdateNode_updatesNode(t *C) {
	ni := graph.NodeInfo{
		Name: "thing.txt",
		Mode: 0755,
	}

	id, err := suite.createNode(suite.ng.RootNode.Id, ni)
	t.Check(err, IsNil)

	ni.Name = "abcd.ghi"
	ni.Mode = 0700

	endpoint := api.UpdateNode.Build(id)
	req := suite.request(endpoint, encode(ni))

	resp, err := suite.client.Do(req)
	t.Check(err, IsNil)
	t.Check(resp.StatusCode, Equals, http.StatusOK)

	changedNode := suite.ng.RootNode.Children()[0]
	t.Check(changedNode.Name(), Equals, ni.Name)
	t.Check(changedNode.Mode(), Equals, ni.Mode)
	t.Check(changedNode.Size(), Equals, ni.Size)
}