mirror of
https://github.com/foomo/contentserver.git
synced 2025-10-16 12:25:44 +00:00
added more client methods
This commit is contained in:
parent
b8102b5164
commit
c0b61188de
@ -52,12 +52,18 @@ func (c *Client) GetURIs(dimension string, IDs []string) (uriMap map[string]stri
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) GetNodes(r *requests.Nodes) (nodes map[string]*content.Node, err error) {
|
// GetNodes request nodes
|
||||||
nodes = map[string]*content.Node{}
|
func (c *Client) GetNodes(env *requests.Env, nodes map[string]*requests.Node) (nodesResponse map[string]*content.Node, err error) {
|
||||||
err = c.call(server.HandlerUpdate, r, &nodes)
|
r := &requests.Nodes{
|
||||||
|
Env: env,
|
||||||
|
Nodes: nodes,
|
||||||
|
}
|
||||||
|
nodesResponse = map[string]*content.Node{}
|
||||||
|
err = c.call(server.HandlerGetNodes, r, &nodesResponse)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetRepo get the whole repo
|
||||||
func (c *Client) GetRepo() (response map[string]*content.RepoNode, err error) {
|
func (c *Client) GetRepo() (response map[string]*content.RepoNode, err error) {
|
||||||
response = map[string]*content.RepoNode{}
|
response = map[string]*content.RepoNode{}
|
||||||
err = c.call(server.HandlerGetRepo, &requests.Repo{}, &response)
|
err = c.call(server.HandlerGetRepo, &requests.Repo{}, &response)
|
||||||
|
|||||||
@ -70,7 +70,30 @@ func TestGetRepo(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
t.Log(r)
|
if r["dimension_foo"].Nodes["id-a"].Data["baz"].(float64) != float64(1) {
|
||||||
|
t.Fatal("failed to drill deep for data")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestGetNodes(t *testing.T) {
|
||||||
|
c := getTestClient(t)
|
||||||
|
nodesRequest := mock.MakeNodesRequest()
|
||||||
|
nodes, err := c.GetNodes(nodesRequest.Env, nodesRequest.Nodes)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
testNode, ok := nodes["test"]
|
||||||
|
if !ok {
|
||||||
|
t.Fatal("that should be a node")
|
||||||
|
}
|
||||||
|
testData, ok := testNode.Item.Data["foo"]
|
||||||
|
if !ok {
|
||||||
|
t.Fatal("where is foo")
|
||||||
|
}
|
||||||
|
if testData != "bar" {
|
||||||
|
t.Fatal("testData should have bennd bar not", testData)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetContent(t *testing.T) {
|
func TestGetContent(t *testing.T) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user