Ejemplo n.º 1
0
func TestConduitQuery(t *testing.T) {
	s := server.New()
	defer s.Close()
	s.RegisterCapabilities()

	s.RegisterMethod("conduit.query", 200, gin.H{
		"result": gin.H{
			"phid.query": gin.H{
				"description": "Retrieve information about arbitrary PHIDs.",
				"params": gin.H{
					"phids": "required list<phid>",
				},
				"return": "nonempty dict<string, wild>",
			},
		},
	})

	c, err := Dial(s.GetURL(), &core.ClientOptions{
		APIToken: "some-token",
	})
	assert.Nil(t, err)

	r, err := c.ConduitQuery()
	assert.Nil(t, err)

	assert.Equal(
		t,
		"nonempty dict<string, wild>",
		(*r)["phid.query"].Return,
	)
}
Ejemplo n.º 2
0
func TestDial(t *testing.T) {
	s := server.New()
	defer s.Close()

	s.RegisterCapabilities()

	_, err := Dial(s.GetURL(), &core.ClientOptions{
		APIToken: "some-token",
	})

	assert.Nil(t, err)
}
Ejemplo n.º 3
0
func TestDial_withInvalid(t *testing.T) {
	s := server.New()
	defer s.Close()

	s.RegisterMethod("conduit.getcapabilities", 200, gin.H{
		"fake": "fake",
	})

	_, err := Dial(s.GetURL(), &core.ClientOptions{
		APIToken: "some-token",
	})

	assert.NotNil(t, err)
}