mirror of https://github.com/containers/podman.git
apiv2 binding test fixes
a recent refactor in the bindings broke the tests. quick fixes to get them working again. Signed-off-by: Brent Baude <bbaude@redhat.com>
This commit is contained in:
parent
66bb873390
commit
a8b4e986f7
|
@ -115,11 +115,12 @@ func (c *Connection) DoRequest(httpBody io.Reader, httpMethod, endpoint string,
|
||||||
)
|
)
|
||||||
safePathValues := make([]interface{}, len(pathValues))
|
safePathValues := make([]interface{}, len(pathValues))
|
||||||
// Make sure path values are http url safe
|
// Make sure path values are http url safe
|
||||||
for _, pv := range pathValues {
|
for i, pv := range pathValues {
|
||||||
safePathValues = append(safePathValues, url.QueryEscape(pv))
|
safePathValues[i] = url.QueryEscape(pv)
|
||||||
}
|
}
|
||||||
|
// Lets eventually use URL for this which might lead to safer
|
||||||
|
// usage
|
||||||
safeEndpoint := fmt.Sprintf(endpoint, safePathValues...)
|
safeEndpoint := fmt.Sprintf(endpoint, safePathValues...)
|
||||||
|
|
||||||
e := c.makeEndpoint(safeEndpoint)
|
e := c.makeEndpoint(safeEndpoint)
|
||||||
req, err := http.NewRequest(httpMethod, e, httpBody)
|
req, err := http.NewRequest(httpMethod, e, httpBody)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -150,8 +151,8 @@ func GetConnectionFromContext(ctx context.Context) (*Connection, error) {
|
||||||
if c == nil {
|
if c == nil {
|
||||||
return nil, errors.New("unable to get connection from context")
|
return nil, errors.New("unable to get connection from context")
|
||||||
}
|
}
|
||||||
conn := c.(Connection)
|
conn := c.(*Connection)
|
||||||
return &conn, nil
|
return conn, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// FiltersToHTML converts our typical filter format of a
|
// FiltersToHTML converts our typical filter format of a
|
||||||
|
|
|
@ -15,6 +15,7 @@ import (
|
||||||
|
|
||||||
const (
|
const (
|
||||||
defaultPodmanBinaryLocation string = "/usr/bin/podman"
|
defaultPodmanBinaryLocation string = "/usr/bin/podman"
|
||||||
|
alpine string = "docker.io/library/alpine:latest"
|
||||||
)
|
)
|
||||||
|
|
||||||
type bindingTest struct {
|
type bindingTest struct {
|
||||||
|
|
|
@ -34,7 +34,7 @@ var _ = Describe("Podman images", func() {
|
||||||
//podmanTest.Setup()
|
//podmanTest.Setup()
|
||||||
//podmanTest.SeedImages()
|
//podmanTest.SeedImages()
|
||||||
bt = newBindingTest()
|
bt = newBindingTest()
|
||||||
p := bt.runPodman([]string{"pull", "docker.io/library/alpine:latest"})
|
p := bt.runPodman([]string{"pull", alpine})
|
||||||
p.Wait(45)
|
p.Wait(45)
|
||||||
s = bt.startAPIService()
|
s = bt.startAPIService()
|
||||||
time.Sleep(1 * time.Second)
|
time.Sleep(1 * time.Second)
|
||||||
|
@ -69,12 +69,12 @@ var _ = Describe("Podman images", func() {
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
// Inspect by ID
|
// Inspect by ID
|
||||||
//Inspect by long name should work, it doesnt (yet) i think it needs to be html escaped
|
//Inspect by long name should work, it doesnt (yet) i think it needs to be html escaped
|
||||||
//_, err = images.GetImage(connText, )
|
//_, err = images.GetImage(connText, alpine, nil)
|
||||||
//Expect(err).To(BeNil())
|
//Expect(err).To(BeNil())
|
||||||
})
|
})
|
||||||
It("remove image", func() {
|
It("remove image", func() {
|
||||||
// Remove invalid image should be a 404
|
// Remove invalid image should be a 404
|
||||||
_, err = images.RemoveImage(connText, "foobar5000", &false)
|
_, err = images.Remove(connText, "foobar5000", &false)
|
||||||
Expect(err).ToNot(BeNil())
|
Expect(err).ToNot(BeNil())
|
||||||
code, _ := bindings.CheckResponseCode(err)
|
code, _ := bindings.CheckResponseCode(err)
|
||||||
Expect(code).To(BeNumerically("==", 404))
|
Expect(code).To(BeNumerically("==", 404))
|
||||||
|
@ -82,7 +82,7 @@ var _ = Describe("Podman images", func() {
|
||||||
_, err := images.GetImage(connText, "alpine", nil)
|
_, err := images.GetImage(connText, "alpine", nil)
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
|
|
||||||
response, err := images.RemoveImage(connText, "alpine", &false)
|
response, err := images.Remove(connText, "alpine", &false)
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
fmt.Println(response)
|
fmt.Println(response)
|
||||||
// to be continued
|
// to be continued
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
package test_bindings_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
. "github.com/onsi/ginkgo"
|
||||||
|
. "github.com/onsi/gomega"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestTest(t *testing.T) {
|
||||||
|
RegisterFailHandler(Fail)
|
||||||
|
RunSpecs(t, "Test Suite")
|
||||||
|
}
|
Loading…
Reference in New Issue