示例#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,
	)
}
示例#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)
}
示例#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)
}