Ejemplo n.º 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)
	}
}
Ejemplo n.º 2
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)
}