Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
Signed-off-by: Qiaozp <[email protected]>
  • Loading branch information
chivalryq committed May 10, 2023
1 parent 65b0914 commit 6649eeb
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions e2e-test/plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package e2e_test

import (
"cuelang.org/go/pkg/strings"
"fmt"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
corev1 "k8s.io/api/core/v1"
Expand All @@ -26,6 +27,13 @@ import (
"github.com/kubevela/velaux/pkg/server/utils/bcode"
)

func enablePlugin(id string) {
res := post(fmt.Sprintf("/manage/plugins/%s/enable", id), nil)
var dto apisv1.PluginDTO
Expect(decodeResponseBody(res, &dto)).Should(Succeed())
Expect(dto.ID).Should(Equal(id))
}

var _ = Describe("Test the plugin rest api", func() {
Context("Test manage plugin API", func() {
By("Request to /manage/plugins")
Expand Down Expand Up @@ -114,11 +122,7 @@ var _ = Describe("Test the plugin rest api", func() {
Expect(strings.Contains(err.Error(), "the plugin is not enabled")).Should(BeTrue())

By("After enable the plugin, request the plugin API should return 200")

res = post("/manage/plugins/node-dashboard/enable", nil)
var dto apisv1.PluginDTO
Expect(decodeResponseBody(res, &dto)).Should(Succeed())
Expect(dto.ID).Should(Equal("node-dashboard"))
enablePlugin("node-dashboard")

res = get(baseDomain + "/proxy/plugins/node-dashboard/api/v1/nodes")
Expect(decodeResponseBody(res, &nodeList)).Should(Succeed())
Expand All @@ -131,8 +135,17 @@ var _ = Describe("Test the plugin rest api", func() {

It("Test to get the module file", func() {
defer GinkgoRecover()
By("Before enable the plugin, request the plugin API should return 400")

res := get(baseDomain + "/public/plugins/app-demo/module.js")
defer func() { _ = res.Body.Close() }()
Expect(res.StatusCode).Should(Equal(400))

By("After enable the plugin, request the plugin API should return 200")
enablePlugin("app-demo")

res = get(baseDomain + "/public/plugins/app-demo/module.js")
defer func() { _ = res.Body.Close() }()
Expect(res.StatusCode).Should(Equal(200))
})
})
Expand Down

0 comments on commit 6649eeb

Please sign in to comment.